Development Book V18: Http Route

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.

whatsapp_icon
location

Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

location

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

location

Bangalore

Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message