Skip to content

Commit 008cc3f

Browse files
authored
Merge pull request #11462 from internetarchive/fastapi-add-served-by-header
add served by header for fastapi
2 parents 406e767 + 84ec7ee commit 008cc3f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

openlibrary/asgi_app.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,13 @@ def create_app() -> FastAPI:
154154

155155
setup_i18n(app)
156156

157+
@app.middleware("http")
158+
async def add_fastapi_header(request: Request, call_next):
159+
"""Middleware to add a header indicating the response came from FastAPI."""
160+
response = await call_next(request)
161+
response.headers["X-Served-By"] = "FastAPI"
162+
return response
163+
157164
# --- Fast routes (mounted within this app) ---
158165
@app.get("/health")
159166
def health() -> dict[str, str]:

0 commit comments

Comments
 (0)