Abort disconnected requests (#457)

This commit is contained in:
Lianmin Zheng
2024-05-20 18:41:21 -07:00
committed by GitHub
parent 3e684be7a3
commit 8dbdc018a3
8 changed files with 202 additions and 132 deletions

View File

@@ -392,14 +392,4 @@ class APIKeyValidatorMiddleware(BaseHTTPMiddleware):
content={"detail": "Invalid API Key"},
)
response = await call_next(request)
return response
# FIXME: Remove this once we drop support for pydantic 1.x
IS_PYDANTIC_1 = int(pydantic.VERSION.split(".")[0]) == 1
def jsonify_pydantic_model(obj: BaseModel):
if IS_PYDANTIC_1:
return obj.json(ensure_ascii=False)
return obj.model_dump_json()
return response