You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
If the rate limiter is not specifically instantiated as "limiter", it throws this error when adding an endpoint with the rate limiter decorator:
Exception: No "request" or "websocket" argument on function
To Reproduce
rate_limiter = Limiter(key_func=get_remote_address)
app.state.limiter = rate_limiter
app.add_exception_handler(RateLimitExceeded, _rate_limit_exceeded_handler)
Expected behavior
The object should function regardless of what variable it is instantiated under.
Screenshots
If applicable, add screenshots to help explain your problem.
Your app (please complete the following information):
fastapi or starlette?
FastAPI
Version?
0.104.1
slowapi version (have you tried with the latest version)?
0.1.8 Additional context
Add any other context about the problem here.
I have just resorted to using the variable "limiter", which works fine.
The text was updated successfully, but these errors were encountered:
Describe the bug
If the rate limiter is not specifically instantiated as "limiter", it throws this error when adding an endpoint with the rate limiter decorator:
Exception: No "request" or "websocket" argument on function
To Reproduce
rate_limiter = Limiter(key_func=get_remote_address)
app.state.limiter = rate_limiter
app.add_exception_handler(RateLimitExceeded, _rate_limit_exceeded_handler)
@app.get("/home")
@rate_limiter .limit("5/minute")
async def homepage(request: Request):
return {
"message": "Hello world",
}
Expected behavior
The object should function regardless of what variable it is instantiated under.
Screenshots
If applicable, add screenshots to help explain your problem.
Your app (please complete the following information):
FastAPI
0.104.1
0.1.8
Additional context
Add any other context about the problem here.
I have just resorted to using the variable "limiter", which works fine.
The text was updated successfully, but these errors were encountered: