Closed QuartzWarrior closed 5 months ago
RateLimit key function should return both the key and a boolean. If the boolean is false, don't run the said RateLimit. If it is true, the RateLimit will run.
Example:
async def get_api_key(): key = request.headers.get("x-api-key") or request.args.get("api_key") return key, True async def is_premium(): key = request.headers.get("x-api-key") or request.args.get("api_key") prem = False if "prem" in key: prem = True return key, prem app = Quart(__name__) limiter = RateLimiter( app=app, rate=[RateLimit(10, timedelta(minutes=1), get_api_key), RateLimit(20, timedelta(minutes=1), is_premium)], )
( Now any route called will have a different rate limit depending on the key type. )
I think the skip_function introduced in 41e4cc8bd62a7712eae9942c2ea6d548b1b81548 will do what you want here, please reopen if not.
RateLimit key function should return both the key and a boolean. If the boolean is false, don't run the said RateLimit. If it is true, the RateLimit will run.
Example:
( Now any route called will have a different rate limit depending on the key type. )