mirror of https://github.com/tiangolo/fastapi.git
Merge 10b5cb11bc into 272204c0c7
This commit is contained in:
commit
c9e3145473
|
|
@ -1138,6 +1138,11 @@ class FastAPI(Starlette):
|
||||||
scope["root_path"] = self.root_path
|
scope["root_path"] = self.root_path
|
||||||
await super().__call__(scope, receive, send)
|
await super().__call__(scope, receive, send)
|
||||||
|
|
||||||
|
def mount(
|
||||||
|
self, path: str, app: ASGIApp, name: str | None = None
|
||||||
|
) -> None: # pragma: no cover
|
||||||
|
self.router._mount(path, app=app, name=name) # pragma: no cover
|
||||||
|
|
||||||
def add_api_route(
|
def add_api_route(
|
||||||
self,
|
self,
|
||||||
path: str,
|
path: str,
|
||||||
|
|
|
||||||
|
|
@ -993,6 +993,20 @@ class APIRouter(routing.Router):
|
||||||
self.default_response_class = default_response_class
|
self.default_response_class = default_response_class
|
||||||
self.generate_unique_id_function = generate_unique_id_function
|
self.generate_unique_id_function = generate_unique_id_function
|
||||||
|
|
||||||
|
@deprecated(
|
||||||
|
"Mounting sub-application on router is not supported. "
|
||||||
|
"Use the `mount` method of FastAPI instance instead."
|
||||||
|
)
|
||||||
|
def mount(self, *args, **kwargs) -> None: # pragma: no cover
|
||||||
|
raise NotImplementedError(
|
||||||
|
"APIRouter does not support mounting other ASGI applications."
|
||||||
|
)
|
||||||
|
|
||||||
|
def _mount(
|
||||||
|
self, path: str, app: ASGIApp, name: str | None = None
|
||||||
|
) -> None: # pragma: no cover
|
||||||
|
super().mount(path=path, app=app, name=name)
|
||||||
|
|
||||||
def route(
|
def route(
|
||||||
self,
|
self,
|
||||||
path: str,
|
path: str,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue