from fastapi import Request, HTTPException async def api_guard(request: Request, call_next): if "x-api-key" not in request.headers: raise HTTPException(401, "API key required") return await call_next(request)