Spotix-API / backend /app /core /request_id.py
Anish530's picture
Initial commit of full project [remaining backend some parts and frontend to be done yet]
aa27d2d
import uuid
from contextvars import ContextVar
request_id_context_var: ContextVar[str] = ContextVar("request_id", default=None)
def generate_request_id() -> str:
req_id = str(uuid.uuid4())
request_id_context_var.set(req_id)
return req_id
def get_request_id() -> str | None:
return request_id_context_var.get()