From c70f3f119885d299c2987ee86a1e867beeb9ff3d Mon Sep 17 00:00:00 2001 From: dmontagu <35119617+dmontagu@users.noreply.github.com> Date: Fri, 30 Aug 2019 17:05:59 -0700 Subject: [PATCH] :sparkles: Add support for custom route class (#468) --- fastapi/routing.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fastapi/routing.py b/fastapi/routing.py index 08f43bf52..0e8ff9739 100644 --- a/fastapi/routing.py +++ b/fastapi/routing.py @@ -317,11 +317,13 @@ class APIRouter(routing.Router): redirect_slashes: bool = True, default: ASGIApp = None, dependency_overrides_provider: Any = None, + route_class: Type[APIRoute] = APIRoute, ) -> None: super().__init__( routes=routes, redirect_slashes=redirect_slashes, default=default ) self.dependency_overrides_provider = dependency_overrides_provider + self.route_class = route_class def add_api_route( self, @@ -347,7 +349,7 @@ class APIRouter(routing.Router): response_class: Type[Response] = JSONResponse, name: str = None, ) -> None: - route = APIRoute( + route = self.route_class( path, endpoint=endpoint, response_model=response_model,