rebuild(stage-1): establish isolated application skeleton

This commit is contained in:
leefer
2026-07-30 00:46:43 +08:00
parent 6df26a2545
commit 603e73d128
32 changed files with 2691 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
from __future__ import annotations
import uuid
from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse
def install_error_handlers(application: FastAPI) -> None:
@application.exception_handler(Exception)
async def unexpected_error(_request: Request, _error: Exception) -> JSONResponse:
correlation_id = uuid.uuid4().hex
return JSONResponse(
status_code=500,
content={
"error": {
"code": "internal_error",
"message": "服务暂时不可用,请稍后重试。",
"correlation_id": correlation_id,
}
},
)