Extension URLs
Overview of all classes, functions, and other objects related to defining extension URLs.
Read more on Extensions.
URLRoute
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:
django.urls.path("/my/path", my_handler, name="my_name", kwargs={"my_extra": "my_value"})
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),
],
)