Extension URLs APIΒ€
Overview of all classes, functions, and other objects related to defining extension URLs.
Read more on Extensions.
URLRoute dataclass Β€
URLRoute(
path: str,
handler: URLRouteHandler | None = None,
children: Iterable[URLRoute] = list(),
name: str | None = None,
extra: dict[str, Any] = dict(),
)
Bases: object
Framework-agnostic route definition.
This is similar to Django's URLPattern object created with django.urls.path().
The URLRoute must either define a handler function or have a list of child routes children. If both are defined, an error will be raised.
Example:
URLRoute("/my/path", handler=my_handler, name="my_name", extra={"kwargs": {"my_extra": "my_value"}})
Is equivalent to:
With children:
URLRoute(
"/my/path",
name="my_name",
extra={"kwargs": {"my_extra": "my_value"}},
children=[
URLRoute(
"/child/<str:name>/",
handler=my_handler,
name="my_name",
extra={"kwargs": {"my_extra": "my_value"}},
),
URLRoute("/other/<int:id>/", handler=other_handler),
],
)
Attributes:
-
children(Iterable[URLRoute]) β -
extra(dict[str, Any]) β -
handler(URLRouteHandler | None) β -
name(str | None) β -
path(str) β