diff --git a/sanic/app.py b/sanic/app.py index 94eb8bed..493b5d94 100644 --- a/sanic/app.py +++ b/sanic/app.py @@ -180,27 +180,28 @@ class Sanic: strict_slashes = self.strict_slashes def response(handler): - args = [key for key in signature(handler).parameters.keys()] - if args: - if stream: - handler.is_stream = stream + args = list(signature(handler).parameters.keys()) - self.router.add( - uri=uri, - methods=methods, - handler=handler, - host=host, - strict_slashes=strict_slashes, - version=version, - name=name, - ) - return handler - else: + if not args: raise ValueError( "Required parameter `request` missing " "in the {0}() route?".format(handler.__name__) ) + if stream: + handler.is_stream = stream + + self.router.add( + uri=uri, + methods=methods, + handler=handler, + host=host, + strict_slashes=strict_slashes, + version=version, + name=name, + ) + return handler + return response # Shorthand method decorators