File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -125,8 +125,10 @@ def as_route(
125125 """
126126 Decorator used to convert a function into a ``Route`` object.
127127
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``.
130132
131133 :param str path: URL path
132134 :param str methods: HTTP method(s): ``"GET"``, ``"POST"``, ``["GET", "POST"]`` etc.
@@ -142,6 +144,12 @@ def some_func(request):
142144
143145 some_func # Route(path="/example", methods={"GET"}, handler=<function some_func at 0x...>)
144146
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+
145153 # If a route is in another file, you can import it and register it to the server
146154
147155 from .routes import some_func
You can’t perform that action at this time.
0 commit comments