INNER CODE UNIT · Python

dispatch

sunithvs/devb.io · api/main.py:37

    async def dispatch(self, request: Request, call_next):
        if request.url.path in self.EXCLUDED_PATHS or Settings.DEBUG:
            return await call_next(request)

        api_key = request.headers.get("X-API-Key")
        if not api_key:
            return JSONResponse(
                status_code=401,
                content={"detail": "API Key header is missing"}
            )
        
        if api_key not in Settings.API_KEYS:
            return JSONResponse(
                status_code=403,
                content={"detail": "Invalid API Key"}
            )

        return await call_next(request)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…