def process(self, req, resp):
if req.method == 'OPTIONS':
if self.cors_origin is not False:
self.process_preflight_request(req, resp)
response_body = '\n'
response_body += 'nothing here\n\n'
resp.body = response_body
resp.status = falcon.HTTP_200
return
try:
if self.cors_origin is not False:
self.process_preflight_request(req, resp)
self.dispatch(req, resp)
except Exception as e:
self.log.error_trace('process failed')
error_type = type(e)
error_map = {
falcon.errors.HTTPNotFound: http_falcon_handler,
falcon.errors.HTTPMissingParam: http_falcon_handler,
falcon.errors.HTTPInvalidParam: http_falcon_handler,
falcon.errors.HTTPInternalServerError: http_falcon_handler,
}
if self.custom_error_map:
error_map.update(self.custom_error_map)
error_func = error_map.get(error_type)
if error_func:
error_func(req, resp, e)
else:
default_error_handler(req, resp, e)
评论列表
文章目录