diff --git a/services/ml/app/main.py b/services/ml/app/main.py index 82d4c6b..a7f2cde 100644 --- a/services/ml/app/main.py +++ b/services/ml/app/main.py @@ -58,6 +58,18 @@ async def verify_api_key(x_api_key: str = Header(default="")): raise HTTPException(status_code=401, detail="Unauthorized") +# --- User ID Header Dependency --- + +async def get_user_id(x_user_id: str = Header(default="")) -> Optional[str]: + """ + Extract X-User-ID header from incoming requests. + + Returns the user ID if present, or None if not provided. + This is optional — callers decide whether to enforce it. + """ + return x_user_id if x_user_id else None + + # --- Lifespan --- @asynccontextmanager