chore: auto-commit 2026-03-26 20:27

This commit is contained in:
administrator 2026-03-26 20:27:59 +00:00
parent 5f595a95ff
commit 769e197492

View file

@ -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():