When you call any sort of router function (e.g. get
or post
), it takes in a parameter that is either a function or a Route
object. If it's a function, it's then converted to a Route
, and if not, it's left alone. This structure allows variant order of decorators.
For example, the following both work just fine:
@get("/")
@query("a", str)
async def route(a: str):
...
@query("a", str)
@get("/")
async def route(a: str):
...
A Route
object is a dataclass that contains the following attributes:
func
, the actual route functionpath
, the path of the route (None
if it uses path parts)method
, enum containing the method of the routeinputs
, a list of RouteInput
objects that are the inputs for the routedoc
, the description of the routecache_rate
, how often to cache the route response. -1
by default (never cache)errors
, a dict of error handlersextra_types
, extra types for inputsparts
, path partsRoute
Bases: Generic[P, T]
, LoadChecker
Standard Route Wrapper
src/view/routing.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|