From 769e1974920b2ce6243168da8b224d313ac078f7 Mon Sep 17 00:00:00 2001 From: administrator Date: Thu, 26 Mar 2026 20:27:59 +0000 Subject: [PATCH] chore: auto-commit 2026-03-26 20:27 --- app/core/app.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/core/app.py b/app/core/app.py index eb2cced..4dc3359 100644 --- a/app/core/app.py +++ b/app/core/app.py @@ -90,6 +90,28 @@ def create_app() -> FastAPI: async def health_check(): return {"status": "healthy", "service": "mock-api"} + # Add endpoint to display request headers + @app.get("/headers") + async def get_headers(request: Request): + """Return all HTTP headers from the request (excluding sensitive ones).""" + # Get all headers + all_headers = dict(request.headers) + + # Filter out sensitive headers (case-insensitive) + sensitive = {"authorization", "cookie", "set-cookie", "x-api-key"} + filtered = { + k: v for k, v in all_headers.items() + if k.lower() not in sensitive + } + + # Return headers with request metadata + return { + "headers": filtered, + "client_ip": request.client.host if request.client else None, + "method": request.method, + "url": str(request.url) + } + # Redirect root to Swagger documentation @app.get("/") async def root_redirect():