Skip to content

korvex.router

The standalone router, without the App. See The standalone router.

The standalone router: maps a path and method to a handler name.

Guide: https://3d3n-pyc.github.io/korvex/router/

Router

Router()

Maps a path and method to a handler name; never calls your code.

match caches the last CACHE_SIZE lookups; results are read-only.

Guide: https://3d3n-pyc.github.io/korvex/router/

version instance-attribute

version = 0

Goes up each time a route is added or removed.

group

group(prefix: str = '', *, middleware: Sequence[str] | None = None) -> RouteGroup

Returns a RouteGroup that registers routes under prefix.

RouteGroup

RouteGroup(router: Router, prefix: str = '', *, middleware: Sequence[str] | None = None)

Registers routes on a router under a prefix and middleware, from Router.group().

Guide: https://3d3n-pyc.github.io/korvex/router/

route

route(path: str, handler: str, *, method: str = 'GET', middleware: Sequence[str] | None = None) -> None

Registers a route. Its own middleware runs after the group's.

full_path

full_path(path: str) -> str

path with this group's prefix: /api + users -> /api/users.

group

group(prefix: str = '', *, middleware: Sequence[str] | None = None) -> RouteGroup

Returns a nested group. Its middleware runs after this group's.

MethodNotAllowed

The path exists, but not for this method (HTTP 405).

allowed instance-attribute

allowed: list[str]

The methods registered for this path.