def route_wrapper(self, route, req, context, request_args, request_kw,
*decorator_args, **decorator_kw):
_ = decorator_kw.pop('with_context') # ignore this.
_options = decorator_kw
options = get_cors_options(context.app, _options)
if options.get('automatic_options') and req.method == 'OPTIONS':
resp = response.HTTPResponse()
else:
resp = route(req, *request_args, **request_kw)
if resp is not None:
while isawaitable(resp):
resp = await resp
if resp is not None:
request_context = context.request[id(req)]
set_cors_headers(req, resp, context, options)
request_context[SANIC_CORS_EVALUATED] = "1"
return resp
评论列表
文章目录