level 4, changed to HAProxy

This commit is contained in:
2026-11-07 18:18:43 +03:00
parent 124c83e450
commit eb4e00e412
33 changed files with 3932 additions and 231 deletions
+5 -2
View File
@@ -72,7 +72,9 @@ def create_app() -> FastAPI:
version='1.3.0',
lifespan=lifespan,
)
instance_id = load_settings().instance_id
settings = load_settings()
instance_id = settings.instance_id
app_version = settings.app_version
def openapi():
if app.openapi_schema is None:
@@ -83,7 +85,7 @@ def create_app() -> FastAPI:
@app.middleware('http')
async def request_context(request: Request, call_next):
"""Gives every response, including unexpected failures, an X-Request-Id and X-Instance-Id."""
"""Gives every response, including unexpected failures, an X-Request-Id, X-Instance-Id and X-App-Version."""
incoming = request.headers.get('X-Request-Id')
request_id = incoming if incoming and _SAFE_REQUEST_ID.match(incoming) else str(uuid.uuid4())
request.state.request_id = request_id
@@ -94,6 +96,7 @@ def create_app() -> FastAPI:
response = _error(500, 'internal_error', _MESSAGES['internal_error'], request_id)
response.headers['X-Request-Id'] = request_id
response.headers['X-Instance-Id'] = instance_id
response.headers['X-App-Version'] = app_version
return response
@app.exception_handler(ApiError)