def add_websocket_route(self, path: str, route: typing.Callable) -> None: if not inspect.isclass(route): route = asgi_from_websocket(route, self.injector) else: route.injector = self.injector instance = Path(path, route, protocol="websocket") self.router.routes.append(instance)
def add_route( self, path: str, route: typing.Callable, methods: typing.Sequence[str] = ()) -> None: if not inspect.isclass(route): route = asgi_from_http(route, self.injector) if not methods: methods = ("GET", ) else: route.injector = self.injector instance = Path(path, route, protocol="http", methods=methods) self.router.routes.append(instance)