-def api_response(request: sanic.Request, result: Any) -> sanic.HTTPResponse:
- """ Render a response from the query results using the configured
- formatter.
- """
- body = api_impl.format_result(result, request.ctx.format)
- return sanic.response.text(body,
- content_type=CONTENT_TYPE.get(request.ctx.format,
- 'application/json'))
-
-
-@api.on_request # type: ignore[misc]
-async def extract_format(request: sanic.Request) -> Optional[sanic.HTTPResponse]:
- """ Get and check the 'format' parameter and prepare the formatter.
- `ctx.result_type` describes the expected return type and
- `ctx.default_format` the format value to assume when no parameter
- is present.
- """
- assert request.route is not None