feat: DSH编排基建首版(server/tests 88用例/P2插件/8020端口/PORT-NOTE/MOBILE_APP)

This commit is contained in:
2026-09-12 14:20:02 +08:00
commit f6acd20325
128 changed files with 24471 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
"""Request-scoped dependencies shared by the routers."""
from __future__ import annotations
import psycopg
from fastapi import HTTPException, Request
from .auth import Ctx
from .config import Config
from .db import connect
def get_cfg(request: Request) -> Config:
return request.app.state.cfg
def get_ctx(request: Request):
cfg: Config = request.app.state.cfg
try:
conn = connect(cfg)
except psycopg.Error:
# A transient DB outage must degrade to 503, not kill the server.
raise HTTPException(503, "database unavailable, try again shortly")
try:
yield Ctx(cfg, conn)
finally:
conn.close()