diff --git a/CHANGELOG.md b/CHANGELOG.md index e650180..432633b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,9 @@ ### Changed -- Breaking change: allow usage of the request object in the except_when function (thanks @colin99d) +- Added: allow usage of the request object in the except_when function (thanks @colin99d) +- Added more test exemption logic (thanks @colin99) +- Fix logger warning for Python 3.11 deprecation (thanks @kevin868) ## [0.1.9] - 2024-02-05 diff --git a/pyproject.toml b/pyproject.toml index c242b7d..cee0502 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "slowapi" -version = "0.1.9" +version = "0.1.10" description = "A rate limiting extension for Starlette and Fastapi" authors = ["Laurent Savaete "] license = "MIT" diff --git a/slowapi/extension.py b/slowapi/extension.py index 050f882..03dc59a 100644 --- a/slowapi/extension.py +++ b/slowapi/extension.py @@ -487,8 +487,12 @@ def __evaluate_limits( limit_for_header = None for lim in limits: limit_scope = lim.scope or endpoint - if lim.is_exempt(request): + if getattr(lim, "_exempt_when_takes_request", False): + if lim.is_exempt(request): + continue + elif lim.is_exempt(): continue + if lim.methods is not None and request.method.lower() not in lim.methods: continue if lim.per_method: