No need of Request in endpoint
In relation to example in issue #25 , ratelimit works without using Request in endpoint. I havenot used Request in any endpoint of my application but ratelimit works. But documentation strongly suggests to use Request in endpoint. Example:
@router.post('/show',
tags=["show"],
name="show:showToAll")
async def show_to_all(background_tasks: BackgroundTasks, user_id = Form(...) ,db: AsyncIOMotorClient = Depends(get_database), Authorize: AuthJWT = Depends(), language: Optional[str] = "en"):
****code*****
This works with example of issue #25
not for me. I am getting:
Exception: No "request" or "websocket" argument on function "<function test at 0x7f2834c39e50>"
@himalacharya I don't understand how the code would work without the request argument. Can you share a minimal example that reproduces it?
Hi @transfluxus , I ran into the same issue. What worked for me is simply to add:
@router.get("/")
@limiter.limit("5/minute")
async def current_transactions(request: Request):
"YOUR CODE"
return "something"
eventhough request: Request is not used within your function
Hope that helps!