We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Can this project support rate limiting by IP address or individual user tokens?
The text was updated successfully, but these errors were encountered:
hey, hope its useful for u: u can define limiter as Limiter(key_func=get_limiter_key, ...)
def get_limiter_key(request: Request): current_key = request.scope.get("client")[0] request_headers = request.scope.get("headers") limiter_prefix = request.scope.get("root_path") + request.scope.get("path") + ":" for headers in request_headers: if headers[0].decode() == "authorization": current_key = headers[1].decode() break if headers[0].decode() in ("user-agent", "x-real-ip"): current_key += headers[1].decode() # shorter key hash_object = hashlib.sha256(current_key.encode()) current_key = hash_object.hexdigest() limiter_key = re.sub( r":{1,}", ":", re.sub(r"/{1,}", ":", limiter_prefix + current_key), ) return limiter_key
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
Can this project support rate limiting by IP address or individual user tokens?
The text was updated successfully, but these errors were encountered: