routes#
- class litestar.routes.BaseRoute#
Bases:
ABC
Base Route class used by Litestar.
It’s an abstract class meant to be extended.
- class litestar.routes.ASGIRoute#
Bases:
BaseRoute
An ASGI route, handling a single
ASGIRouteHandler
- __init__(*, path: str, route_handler: ASGIRouteHandler) None #
Initialize the route.
- Parameters:
path¶ – The path for the route.
route_handler¶ – An instance of
ASGIRouteHandler
.
- class litestar.routes.WebSocketRoute#
Bases:
BaseRoute
A websocket route, handling a single
WebsocketRouteHandler
- __init__(*, path: str, route_handler: WebsocketRouteHandler) None #
Initialize the route.
- Parameters:
path¶ – The path for the route.
route_handler¶ – An instance of
WebsocketRouteHandler
.
- async handle(scope: WebSocketScope, receive: Receive, send: Send) None #
ASGI app that creates a WebSocket from the passed in args, and then awaits the handler function.
- class litestar.routes.HTTPRoute#
Bases:
BaseRoute
An HTTP route, capable of handling multiple
HTTPRouteHandler
s.- __init__(*, path: str, route_handlers: list[litestar.handlers.http_handlers.base.HTTPRouteHandler]) None #
Initialize
HTTPRoute
.- Parameters:
path¶ – The path for the route.
route_handlers¶ – A list of
HTTPRouteHandler
.
- async handle(scope: HTTPScope, receive: Receive, send: Send) None #
ASGI app that creates a Request from the passed in args, determines which handler function to call and then handles the call.
- create_handler_map() None #
Parse the
router_handlers
of this route and return a mapping of http- methods and route handlers.
- create_options_handler(path: str) HTTPRouteHandler #
- Parameters:
path¶ – The route path
- Returns:
An HTTP route handler for OPTIONS requests.