Skip to content

AttributeError: 'APIWebSocketRoute' object has no attribute 'methods' #61

Open
@HayatoYagi

Description

@HayatoYagi

RateLimiter.__call__ fails when there is a websocket endpoint with the same path.

self = <fastapi_limiter.depends.RateLimiter object at 0x7f85b5f08e50>
request = <starlette.requests.Request object at 0x7f8581ed9a80>
response = <starlette.responses.Response object at 0x7f8581e22fb0>

    async def __call__(self, request: Request, response: Response):
        if not FastAPILimiter.redis:
            raise Exception("You must call FastAPILimiter.init in startup event of fastapi!")
        route_index = 0
        dep_index = 0
        for i, route in enumerate(request.app.routes):
>           if route.path == request.scope["path"] and request.method in route.methods:
E           AttributeError: 'APIWebSocketRoute' object has no attribute 'methods'

../.venv/lib/python3.10/site-packages/fastapi_limiter/depends.py:41: AttributeError

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions