Skip to content

Commit

Permalink
Move middleware out of startup
Browse files Browse the repository at this point in the history
This is required by current versions of FastAPI/Starlette.
  • Loading branch information
jonathansick committed Apr 13, 2023
1 parent 948db84 commit bff6b0f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/timessquare/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
)
"""The FastAPI application for times-square."""

# Add middleware
app.add_middleware(XForwardedMiddleware)

# Add routers
app.include_router(internal_router)
app.include_router(external_router, prefix=f"{config.path_prefix}")
app.include_router(v1_router, prefix=f"{config.path_prefix}/v1")
Expand All @@ -65,7 +69,6 @@ async def startup_event() -> None:
await arq_dependency.initialize(
mode=config.arq_mode, redis_settings=config.arq_redis_settings
)
app.add_middleware(XForwardedMiddleware)


@app.on_event("shutdown")
Expand Down

0 comments on commit bff6b0f

Please sign in to comment.