The monasca_events_api.app.core.validation Module

monasca_events_api.app.core.validation.validate_content_type(req, allowed)[source]

Validates content type.

Method validates request against correct content type.

If content-type cannot be established (i.e. header is missing), falcon.HTTPMissingHeader is thrown. If content-type is not application/json or text/plain, falcon.HTTPUnsupportedMediaType is thrown.

Parameters
  • req (falcon.Request) – current request

  • allowed (iterable) – allowed content type

Exception

falcon.HTTPMissingHeader

Exception

falcon.HTTPUnsupportedMediaType