Files
fastapi-best-architecture/backend/utils/trace_id.py
T
Wu Clan 5762834744 Update the ruff rules and format the code (#846)
* Update the ruff rules and format the code

* Update the per-file-ignores

* Update the ci

* Update rules

* Fix codes

* Fix pagination

* Update rules
2025-10-10 19:02:49 +08:00

14 lines
335 B
Python

from fastapi import Request
from backend.core.conf import settings
def get_request_trace_id(request: Request) -> str:
"""
从请求头中获取追踪 ID
:param request: FastAPI 请求对象
:return:
"""
return request.headers.get(settings.TRACE_ID_REQUEST_HEADER_KEY) or settings.TRACE_ID_LOG_DEFAULT_VALUE