The zaqar.common.transport.wsgi.helpers
module¶
wsgi transport helpers.
-
extract_project_id
(req, resp, params)¶ Adds project_id to the list of params for all responders
Meant to be used as a before hook.
Parameters: - req (falcon.request.Request) – request sent
- resp (falcon.response.Response) – response object to return
- params (dict) – additional parameters passed to responders
Return type: None
-
get_client_uuid
(req)¶ Read a required Client-ID from a request.
Parameters: req – A falcon.Request object Raises: HTTPBadRequest if the Client-ID header is missing or does not represent a valid UUID Returns: A UUID object
-
inject_context
(req, resp, params)¶ Inject context value into request environment.
Parameters: - req (falcon.request.Request) – request sent
- resp (falcon.response.Response) – response object
- params (dict) – additional parameters passed to responders
Return type: None
-
require_accepts_json
(req, resp, params)¶ Raises an exception if the request does not accept JSON
Meant to be used as a before hook.
Parameters: - req (falcon.request.Request) – request sent
- resp (falcon.response.Response) – response object to return
- params (dict) – additional parameters passed to responders
Return type: None
Raises: falcon.HTTPNotAcceptable
-
require_client_id
(req, resp, params)¶ Makes sure the header Client-ID is present in the request
Use as a before hook. :param req: request sent :type req: falcon.request.Request :param resp: response object to return :type resp: falcon.response.Response :param params: additional parameters passed to responders :type params: dict :rtype: None
-
require_content_type_be_non_urlencoded
(req, resp, params)¶ Raises an exception on “x-www-form-urlencoded” content type of request.
If request has body and “Content-Type” header has “application/x-www-form-urlencoded” value (case-insensitive), this function raises falcon.HTTPBadRequest exception.
This strange function exists only to prevent bug/1547100 in a backward compatible way.
Meant to be used as a before hook.
Parameters: - req (falcon.request.Request) – request sent
- resp (falcon.response.Response) – response object to return
- params (dict) – additional parameters passed to responders
Return type: None
Raises: falcon.HTTPBadRequest
-
validate_queue_identification
(validate, req, resp, params)¶ Hook for validating the queue name and project id in requests.
The queue name validation is short-circuited if ‘queue_name’ does not exist in params.
This hook depends on the get_project hook, which must be installed upstream.
Parameters: - validate – A validator function that will be used to check the queue name against configured limits. functools.partial or a closure must be used to set this first arg, and expose the remaining ones as a Falcon hook interface.
- req – Falcon request object
- resp – Falcon response object
- params – Responder params dict
-
verify_pre_signed_url
(key, req, resp, params)¶