Cors request
Cross-Origin Resource Sharing (CORS) handler for odin-control.
This module implements a simple handler to respond to CORS preflight requests from clients, allowing CORS requests to be made to API handlers.
Tim Nicholls, STFC Detector Systems Software Group.
CorsRequestHandler
Bases: RequestHandler
Handler to respond to CORS requests.
This handler responds to HTTP OPTIONS requests and sets the appropriate headers to allow CORS requests from the specified origin. This class is intended to be used as a base class for API handlers to allow CORS requests to be made to API endpoints.
Source code in src/odin_control/http/handlers/cors_request.py
__init__(*args, **kwargs)
Construct the CorsRequestHandler object.
This method constructs the CorsRequestHandler object, calling the superclass constructor and setting the route object to None.
Source code in src/odin_control/http/handlers/cors_request.py
initialize(route, enable_cors, cors_origin)
Initialize the CorsRequestHandler object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
route
|
ApiRoute object calling the handler (allows adapters to be resolved) |
required | |
enable_cors
|
enable CORS support by setting appropriate headers |
required | |
cors_origin
|
allowed origin for CORS requests |
required |
Source code in src/odin_control/http/handlers/cors_request.py
options(*_)
Handle an OPTIONS request.
This method handles an OPTION request and is provided to allow browser clients to employ CORS preflight requests to determine if non-simple requests are allowed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_
|
unused arguments passed to the method by the URI matching in the handler |
()
|