Add all middleware to the FastAPI application.
(app: FastAPI)
| 116 | |
| 117 | |
| 118 | def add_middleware(app: FastAPI): |
| 119 | """Add all middleware to the FastAPI application.""" |
| 120 | # Attach CORS first to handle preflight requests and allow origins. |
| 121 | add_cors_middleware(app) |
| 122 | |
| 123 | # Add other middleware |
| 124 | app.middleware("http")(correlation_id_middleware) |
| 125 | app.middleware("http")(security_middleware) |
| 126 | # app.middleware("http")(rate_limit_middleware) # Enable if needed |
| 127 | |
| 128 | return app |
no test coverage detected