again, fix stupid handler has no _request/response_middleware error

This commit is contained in:
PandaFeeder 2017-05-13 19:10:51 +08:00
parent b1b801f245
commit f26a70cfe0

View File

@ -139,8 +139,6 @@ class Sanic:
"Middleware mounted on a handler should "
"be a function or a sequence of functions"
)
else:
vars(handler)["_"+r+"_middleware"] = ()
self.router.add(uri=uri, methods=methods, handler=handler,
host=host, strict_slashes=strict_slashes)
@ -480,6 +478,7 @@ class Sanic:
"handler from the router"))
# request middleware mounted on handler
if hasattr(handler, "_request_middleware"):
mounted_request_middleware = handler._request_middleware
if mounted_request_middleware:
response = await self._handle_mounted_request_middleware(
@ -496,6 +495,7 @@ class Sanic:
response = await response
# response middleware mounted on handler
if hasattr(handler, "_response_middleware"):
mounted_response_middleware = handler._response_middleware
if mounted_response_middleware:
response = await self._handle_mounted_response_middleware(