again, fix stupid handler has no _request/response_middleware error
This commit is contained in:
parent
b1b801f245
commit
f26a70cfe0
24
sanic/app.py
24
sanic/app.py
|
@ -139,8 +139,6 @@ class Sanic:
|
||||||
"Middleware mounted on a handler should "
|
"Middleware mounted on a handler should "
|
||||||
"be a function or a sequence of functions"
|
"be a function or a sequence of functions"
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
vars(handler)["_"+r+"_middleware"] = ()
|
|
||||||
|
|
||||||
self.router.add(uri=uri, methods=methods, handler=handler,
|
self.router.add(uri=uri, methods=methods, handler=handler,
|
||||||
host=host, strict_slashes=strict_slashes)
|
host=host, strict_slashes=strict_slashes)
|
||||||
|
@ -480,11 +478,12 @@ class Sanic:
|
||||||
"handler from the router"))
|
"handler from the router"))
|
||||||
|
|
||||||
# request middleware mounted on handler
|
# request middleware mounted on handler
|
||||||
mounted_request_middleware = handler._request_middleware
|
if hasattr(handler, "_request_middleware"):
|
||||||
if mounted_request_middleware:
|
mounted_request_middleware = handler._request_middleware
|
||||||
response = await self._handle_mounted_request_middleware(
|
if mounted_request_middleware:
|
||||||
mounted_request_middleware, request, *args, **kwargs
|
response = await self._handle_mounted_request_middleware(
|
||||||
)
|
mounted_request_middleware, request, *args, **kwargs
|
||||||
|
)
|
||||||
# No mounted request middleware result
|
# No mounted request middleware result
|
||||||
if not response:
|
if not response:
|
||||||
# -------------------------------------------- #
|
# -------------------------------------------- #
|
||||||
|
@ -496,11 +495,12 @@ class Sanic:
|
||||||
response = await response
|
response = await response
|
||||||
|
|
||||||
# response middleware mounted on handler
|
# response middleware mounted on handler
|
||||||
mounted_response_middleware = handler._response_middleware
|
if hasattr(handler, "_response_middleware"):
|
||||||
if mounted_response_middleware:
|
mounted_response_middleware = handler._response_middleware
|
||||||
response = await self._handle_mounted_response_middleware(
|
if mounted_response_middleware:
|
||||||
mounted_response_middleware, request, response, *args, **kwargs
|
response = await self._handle_mounted_response_middleware(
|
||||||
)
|
mounted_response_middleware, request, response, *args, **kwargs
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user