创建 outlook_web/middleware/ 目录,从 legacy.py 迁移: 新增文件: - middleware/__init__.py - 模块导出 - middleware/trace.py - trace_id 中间件 - ensure_trace_id(): 为每个请求生成/透传 trace_id - attach_trace_id_and_normalize_errors(): 统一写入 X-Trace-Id,标准化错误格式 - middleware/error_handler.py - 错误处理中间件 - handle_http_exception(): 处理 HTTP 异常 - handle_exception(): 处理未捕获异常 更新文件: - app.py: 从 middleware 模块导入,替代 legacy 引用 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
17 lines
365 B
Python
17 lines
365 B
Python
# Middleware module
|
|
from outlook_web.middleware.trace import (
|
|
ensure_trace_id,
|
|
attach_trace_id_and_normalize_errors,
|
|
)
|
|
from outlook_web.middleware.error_handler import (
|
|
handle_http_exception,
|
|
handle_exception,
|
|
)
|
|
|
|
__all__ = [
|
|
"ensure_trace_id",
|
|
"attach_trace_id_and_normalize_errors",
|
|
"handle_http_exception",
|
|
"handle_exception",
|
|
]
|