Skip to content

bareasgi.basic_router

module bareasgi.basic_router.http_router

Summary

Http Routing

class BasicHttpRouter(HttpRouter)

Summary

A basic http routing implementation

bareasgi.basic_router.BasicHttpRouter(
not_found_response: HttpResponse
) -> None

Parameters

not_found_response: HttpResponse

property BasicHttpRouter.not_found_response

Summary

The response when a handler could not be found for a method/path

not_found_response -> HttpResponse
not_found_response: HttpResponse = ...

method BasicHttpRouter.add

Summary

Add an HTTP request handler

BasicHttpRouter.add(
methods: AbstractSet[str],
path: str,
callback: HttpRequestCallback
) -> Any

Parameters

methods: AbstractSet[str]

The supported HTTP methods.

path: str

The path.

callback: HttpRequestCallback

The request handler.

Returns

Any:

method BasicHttpRouter.add_route

Summary

Add a route to a callback for a method and path definition

BasicHttpRouter.add_route(
method: str,
path_definition: PathDefinition,
callback: HttpRequestCallback
) -> Any

Parameters

method: str

The method.

path_definition: PathDefinition

The path definition

callback: HttpRequestCallback

The callback

Returns

Any:

method BasicHttpRouter.resolve

Summary

Resolve a request to a handler with the route matches

BasicHttpRouter.resolve(
method: str,
path: str
) -> Tuple[HttpRequestCallback, Mapping[str, Any]]

Parameters

method: str

The HTTP method.

path: str

The path.

Returns

Tuple[HttpRequestCallback, Mapping[str, Any]]: A handler and the route matches.

module bareasgi.basic_router.web_socket_router

Summary

A basic Websocket router.

class BasicWebSocketRouter(WebSocketRouter)

Summary

The implementation of a basic Websocket router

bareasgi.basic_router.BasicWebSocketRouter() -> None

method BasicWebSocketRouter.add

Summary

Add the WebSocket handler for a route

BasicWebSocketRouter.add(
path: str,
callback: WebSocketRequestCallback
) -> Any

Parameters

path: str

The path.

callback: WebSocketRequestCallback

The handler

Returns

Any:

method BasicWebSocketRouter.resolve

Summary

Resolve a route to a handler

BasicWebSocketRouter.resolve(
path: str
) -> Tuple[WebSocketRequestCallback, Mapping[str, Any]]

Parameters

path: str

The path

Returns

Tuple[WebSocketRequestCallback, Mapping[str, Any]]: A handler and the route matches