INNER CODE UNIT · Python

__init__

mouseart2025/AI-Reader-V2 · backend/src/api/main.py:123

    def __init__(self, app):
        self.app = app

    async def __call__(self, scope, receive, send):
        if scope["type"] not in ("http", "websocket"):
            return await self.app(scope, receive, send)
        from src.infra import config  # 运行时读取,便于测试注入
        token = config.SIDECAR_TOKEN
        path = scope.get("path", "")
        if (
            not token
            or path == "/api/health"
            or not (path.startswith("/api/") or path.startswith("/ws/"))
            or (scope["type"] == "http" and scope.get("method") == "OPTIONS")
        ):
            return await self.app(scope, receive, send)

        if scope["type"] == "http":

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…