mirror of https://github.com/tiangolo/fastapi.git
Add `router_class` param
This commit is contained in:
parent
efee7a407d
commit
25419b7c39
|
|
@ -810,6 +810,17 @@ class FastAPI(Starlette):
|
|||
"""
|
||||
),
|
||||
] = True,
|
||||
router_class: Annotated[
|
||||
Type[routing.APIRouter],
|
||||
Doc(
|
||||
"""
|
||||
The default router class to be used.
|
||||
|
||||
Read more in the
|
||||
[FastAPI docs for Custom Router](Bigger Applications - Multiple Files).
|
||||
"""
|
||||
),
|
||||
] = routing.APIRouter,
|
||||
**extra: Annotated[
|
||||
Any,
|
||||
Doc(
|
||||
|
|
@ -893,7 +904,7 @@ class FastAPI(Starlette):
|
|||
[FastAPI docs for OpenAPI Webhooks](https://fastapi.tiangolo.com/advanced/openapi-webhooks/).
|
||||
"""
|
||||
),
|
||||
] = webhooks or routing.APIRouter()
|
||||
] = webhooks or router_class()
|
||||
self.root_path = root_path or openapi_prefix
|
||||
self.state: Annotated[
|
||||
State,
|
||||
|
|
@ -929,7 +940,7 @@ class FastAPI(Starlette):
|
|||
"""
|
||||
),
|
||||
] = {}
|
||||
self.router: routing.APIRouter = routing.APIRouter(
|
||||
self.router: routing.APIRouter = router_class(
|
||||
routes=routes,
|
||||
redirect_slashes=redirect_slashes,
|
||||
dependency_overrides_provider=self,
|
||||
|
|
|
|||
Loading…
Reference in New Issue