chore: auto-commit 2026-03-26 20:27
This commit is contained in:
parent
5f595a95ff
commit
769e197492
1 changed files with 22 additions and 0 deletions
|
|
@ -90,6 +90,28 @@ def create_app() -> FastAPI:
|
||||||
async def health_check():
|
async def health_check():
|
||||||
return {"status": "healthy", "service": "mock-api"}
|
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
|
# Redirect root to Swagger documentation
|
||||||
@app.get("/")
|
@app.get("/")
|
||||||
async def root_redirect():
|
async def root_redirect():
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue