Spaces:
Sleeping
Sleeping
File size: 383 Bytes
c8f4a46 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | import uuid
from typing import Annotated
from fastapi import Header
async def get_session_id(x_session_id: Annotated[str | None, Header()] = None) -> str:
"""
Return the session ID from the X-Session-Id header.
If the header is absent, generate a fresh UUID so every resource
is still scoped to *some* session.
"""
return x_session_id or str(uuid.uuid4())
|