File tree 1 file changed +10
-2
lines changed
1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -125,8 +125,10 @@ def as_route(
125
125
"""
126
126
Decorator used to convert a function into a ``Route`` object.
127
127
128
- It is a shorthand for manually creating a ``Route`` object, that can be used only one time
129
- per function. Later it can be imported and registered in the ``Server``.
128
+ ``as_route`` can be only used once per function, because it replaces the function with
129
+ a ``Route`` object that has the same name as the function.
130
+
131
+ Later it can be imported and registered in the ``Server``.
130
132
131
133
:param str path: URL path
132
134
:param str methods: HTTP method(s): ``"GET"``, ``"POST"``, ``["GET", "POST"]`` etc.
@@ -142,6 +144,12 @@ def some_func(request):
142
144
143
145
some_func # Route(path="/example", methods={"GET"}, handler=<function some_func at 0x...>)
144
146
147
+ # WRONG: as_route can be used only once per function
148
+ @as_route("/wrong-example1")
149
+ @as_route("/wrong-example2")
150
+ def wrong_func2(request):
151
+ ...
152
+
145
153
# If a route is in another file, you can import it and register it to the server
146
154
147
155
from .routes import some_func
You can’t perform that action at this time.
0 commit comments