Skip to content

Commit

Permalink
update default_identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
long2ice committed Apr 29, 2021
1 parent 039f8f0 commit 6f3c85a
Show file tree
Hide file tree
Showing 2 changed files with 212 additions and 210 deletions.
6 changes: 4 additions & 2 deletions fastapi_limiter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
async def default_identifier(request: Request):
forwarded = request.headers.get("X-Forwarded-For")
if forwarded:
return forwarded.split(",")[0]
return request.client.host + ":" + request.scope["path"]
ip = forwarded.split(",")[0]
else:
ip = request.client.host
return ip + ":" + request.scope["path"]


async def default_callback(request: Request, response: Response, pexpire: int):
Expand Down
Loading

0 comments on commit 6f3c85a

Please sign in to comment.