forked from orbit-oss/flask
Allow passing the endpoint to the route decorators on Flask's application and blueprints.
This commit is contained in:
parent
1bca65d72e
commit
68ec5a3068
3 changed files with 64 additions and 2 deletions
|
|
@ -942,7 +942,8 @@ class Flask(_PackageBoundObject):
|
|||
:class:`~werkzeug.routing.Rule` object.
|
||||
"""
|
||||
def decorator(f):
|
||||
self.add_url_rule(rule, None, f, **options)
|
||||
endpoint = options.pop("endpoint", None)
|
||||
self.add_url_rule(rule, endpoint, f, **options)
|
||||
return f
|
||||
return decorator
|
||||
|
||||
|
|
|
|||
|
|
@ -157,7 +157,8 @@ class Blueprint(_PackageBoundObject):
|
|||
:func:`url_for` function is prefixed with the name of the blueprint.
|
||||
"""
|
||||
def decorator(f):
|
||||
self.add_url_rule(rule, f.__name__, f, **options)
|
||||
endpoint = options.pop("endpoint", f.__name__)
|
||||
self.add_url_rule(rule, endpoint, f, **options)
|
||||
return f
|
||||
return decorator
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue