Browse Source

Add support for custom route class (#468)

pull/490/head
dmontagu 6 years ago
committed by Sebastián Ramírez
parent
commit
c70f3f1198
  1. 4
      fastapi/routing.py

4
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,

Loading…
Cancel
Save