HTTP routes serve as the pathways that link user requests (URLs) to
designated functions within an application like Odoo. They function
like traffic controllers, guiding each incoming request to the
correct handler for processing and response.
from odoo import http
@http.route('/product', type='http', auth="user", website=True)
Within the @http.route() decorator, several parameters can be
configured:
- url: Specifies the URL path to be routed. For example,
'/contacts' defines the URL endpoint.
- type: Indicates the request type. Supported options are
'http' or 'json'. The 'http' type returns a template response,
using the provided dictionary, while 'json' is used for JSON RPC
calls from JavaScript.
- auth: Controls access permissions for the route:
- auth='public': Grants open access to everyone
- auth='user': Restricts access to authenticated users.
- auth='none': Typically used in authentication-related
modules, allowing internal access without standard
authentication.
- website: Specifies whether the route is connected to a
web page. Accepts either True or False.
These parameters help define how requests are handled and who can
access them.