Browse Source

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.
pull/1338/head
Chris Rebert 10 years ago
parent
commit
eccee36964
  1. 8
      flask/app.py

8
flask/app.py

@ -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…
Cancel
Save