[1/N] API Server (Remove Proxy) (#11529)

This commit is contained in:
Robert Shaw
2024-12-26 18:03:43 -05:00
committed by GitHub
parent b85a977822
commit 720b10fdc6
2 changed files with 17 additions and 7 deletions

View File

@@ -585,12 +585,18 @@ def build_app(args: Namespace) -> FastAPI:
status_code=401)
return await call_next(request)
@app.middleware("http")
async def add_request_id(request: Request, call_next):
request_id = request.headers.get("X-Request-Id") or uuid.uuid4().hex
response = await call_next(request)
response.headers["X-Request-Id"] = request_id
return response
if args.enable_request_id_headers:
logger.warning(
"CAUTION: Enabling X-Request-Id headers in the API Server. "
"This can harm performance at high QPS.")
@app.middleware("http")
async def add_request_id(request: Request, call_next):
request_id = request.headers.get(
"X-Request-Id") or uuid.uuid4().hex
response = await call_next(request)
response.headers["X-Request-Id"] = request_id
return response
for middleware in args.middleware:
module_path, object_name = middleware.rsplit(".", 1)