forked from orbit-oss/flask
Document required signature of before_request functions
Unless you happened to also read preprocess_request()'s docstring, it wasn't not obvious that return values from these functions are treated as response values.
This commit is contained in:
parent
a45fce8496
commit
eccee36964
1 changed files with 7 additions and 1 deletions
|
|
@ -1243,7 +1243,13 @@ class Flask(_PackageBoundObject):
|
|||
|
||||
@setupmethod
|
||||
def before_request(self, f):
|
||||
"""Registers a function to run before each request."""
|
||||
"""Registers a function to run before each request.
|
||||
|
||||
The function will be called without any arguments.
|
||||
If the function returns a non-None value, it's handled as
|
||||
if it was the return value from the view and further
|
||||
request handling is stopped.
|
||||
"""
|
||||
self.before_request_funcs.setdefault(None, []).append(f)
|
||||
return f
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue