Warning: Bocadillo is now UNMAINTAINED. Users are recommended to migrate to a supported alternative, such as Starlette or FastAPI. Please see #344 for more information.

bocadillo.routing

Router

Router(self)

include

Router.include(self, other:'Router', prefix:str='')

Include the routes of another router.

mount

Router.mount(self, path:str, app:bocadillo.app_types.ASGIApp)

Mount an ASGI or WSGI app at the given path.

route

Router.route(self, pattern:str, methods:List[str]=None)

Register an HTTP route by decorating a view.

Parameters

  • pattern (str): an URL pattern.

websocket_route

Router.websocket_route(self, pattern:str, *, auto_accept:bool=True, value_type:str=None, receive_type:str=None, send_type:str=None, caught_close_codes:Tuple[int]=None)

Register a WebSocket route by decorating a view.

See #::bocadillo.websockets#WebSocket for a description of keyword parameters.

Parameters

  • pattern (str): an URL pattern.