Browse Source

Merge 10b5cb11bc into 6df50d40fe

pull/13944/merge
Motov Yurii 4 days ago
committed by GitHub
parent
commit
f7ef6f7844
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 5
      fastapi/applications.py
  2. 14
      fastapi/routing.py

5
fastapi/applications.py

@ -1053,6 +1053,11 @@ class FastAPI(Starlette):
scope["root_path"] = self.root_path
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(
self,
path: str,

14
fastapi/routing.py

@ -860,6 +860,20 @@ class APIRouter(routing.Router):
self.default_response_class = default_response_class
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(
self,
path: str,

Loading…
Cancel
Save