feat(sensor-placement): add editable scheme APIs

This commit is contained in:
2026-07-30 16:16:51 +08:00
parent 437eb5a19a
commit ddbb50173c
13 changed files with 1313 additions and 122 deletions
+2 -18
View File
@@ -58,6 +58,8 @@ class AuditMiddleware(BaseHTTPMiddleware):
"/meta/projects",
"/api/v1/openproject/",
"/openproject/",
"/api/v1/audit/session-events",
"/audit/session-events",
}
EXCLUDED_PATH_PREFIXES = (
)
@@ -80,27 +82,9 @@ class AuditMiddleware(BaseHTTPMiddleware):
request_data = None
if should_capture_body:
try:
# 注意:读取 body 后需要重新设置,避免影响后续处理
original_receive = request._receive
body = await request.body()
if body:
request_data = json.loads(body.decode())
# 重新构造请求以供后续使用:仅回放一次,后续回落原始 receive
body_sent = False
async def receive():
nonlocal body_sent
if not body_sent:
body_sent = True
return {
"type": "http.request",
"body": body,
"more_body": False,
}
return await original_receive()
request._receive = receive
except Exception as e:
logger.warning(f"Failed to read request body for audit: {e}")