Refactor the app.route decorator
This commit is contained in:
parent
653ac7ee14
commit
de582d2fc7
15
sanic/app.py
15
sanic/app.py
|
@ -180,8 +180,14 @@ class Sanic:
|
||||||
strict_slashes = self.strict_slashes
|
strict_slashes = self.strict_slashes
|
||||||
|
|
||||||
def response(handler):
|
def response(handler):
|
||||||
args = [key for key in signature(handler).parameters.keys()]
|
args = list(signature(handler).parameters.keys())
|
||||||
if args:
|
|
||||||
|
if not args:
|
||||||
|
raise ValueError(
|
||||||
|
"Required parameter `request` missing "
|
||||||
|
"in the {0}() route?".format(handler.__name__)
|
||||||
|
)
|
||||||
|
|
||||||
if stream:
|
if stream:
|
||||||
handler.is_stream = stream
|
handler.is_stream = stream
|
||||||
|
|
||||||
|
@ -195,11 +201,6 @@ class Sanic:
|
||||||
name=name,
|
name=name,
|
||||||
)
|
)
|
||||||
return handler
|
return handler
|
||||||
else:
|
|
||||||
raise ValueError(
|
|
||||||
"Required parameter `request` missing "
|
|
||||||
"in the {0}() route?".format(handler.__name__)
|
|
||||||
)
|
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user