Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
HayatoYagi opened this issue Sep 20, 2024 · 0 comments · May be fixed by #62
Open

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

HayatoYagi opened this issue Sep 20, 2024 · 0 comments · May be fixed by #62

Comments

@HayatoYagi
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant