1111from fastapi import Depends , FastAPI
1212
1313from .config import Settings
14- from .handlers import OpenApiSpecHandler
1514from .middleware import AddProcessTimeHeaderMiddleware
16- from .proxy import ReverseProxy
15+ from .handlers import ReverseProxyHandler , OpenApiSpecHandler
1716
1817
1918def create_app (settings : Optional [Settings ] = None ) -> FastAPI :
2019 """FastAPI Application Factory."""
2120 settings = settings or Settings ()
2221
2322 app = FastAPI (openapi_url = None )
24-
2523 app .add_middleware (AddProcessTimeHeaderMiddleware )
2624
2725 auth_scheme = OpenIdConnectAuth (
2826 openid_configuration_url = str (settings .oidc_discovery_url )
2927 ).valid_token_dependency
3028
31- proxy = ReverseProxy (upstream = str (settings .upstream_url ))
32-
29+ proxy_handler = ReverseProxyHandler (upstream = str (settings .upstream_url ))
3330 openapi_handler = OpenApiSpecHandler (
34- proxy = proxy , oidc_config_url = str (settings .oidc_discovery_url )
35- ). dispatch
31+ proxy = proxy_handler , oidc_config_url = str (settings .oidc_discovery_url )
32+ )
3633
3734 # Endpoints that are explicitely marked private
3835 for path , methods in settings .private_endpoints .items ():
3936 app .add_api_route (
4037 path ,
4138 (
42- proxy .stream
39+ proxy_handler .stream
4340 if path != settings .openapi_spec_endpoint
44- else openapi_handler
41+ else openapi_handler . dispatch
4542 ),
4643 methods = methods ,
4744 dependencies = [Depends (auth_scheme )],
@@ -52,17 +49,17 @@ def create_app(settings: Optional[Settings] = None) -> FastAPI:
5249 app .add_api_route (
5350 path ,
5451 (
55- proxy .stream
52+ proxy_handler .stream
5653 if path != settings .openapi_spec_endpoint
57- else openapi_handler
54+ else openapi_handler . dispatch
5855 ),
5956 methods = methods ,
6057 )
6158
6259 # Catchall for remainder of the endpoints
6360 app .add_api_route (
6461 "/{path:path}" ,
65- proxy .stream ,
62+ proxy_handler .stream ,
6663 methods = ["GET" , "POST" , "PUT" , "PATCH" , "DELETE" ],
6764 dependencies = ([] if settings .default_public else [Depends (auth_scheme )]),
6865 )
0 commit comments