Skip to content
New issue

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

Use limits directly instead of Flask-Limiter #915

Merged
merged 3 commits into from
Feb 26, 2024
Merged

Conversation

psrok1
Copy link
Member

@psrok1 psrok1 commented Feb 21, 2024

Your checklist for this pull request

  • I've read the contributing guideline.
  • I've tested my changes by building and running the project, and testing changed functionality (if applicable)
  • I've added automated tests for my change (if applicable, optional)
  • I've updated documentation to reflect my change (if applicable)

What is the current behaviour?

I tried to modify something around limits and feel that Flask-Limiter is not exactly a good fit to our needs. rate_limited_resource decorator is awfully hacky and Flask-Limiter doesn't provide a good way to make more dynamic configuration of limits.

What is the new behaviour?

In the same time: Flask-Limiter is just a wrapper on limits library. I found we can use it directly and implement rate limiting in before_request instead of relying on decorators

Test plan

  1. Enabled rate limits and set pretty low limit for method and resource
  2. Hit the limit and checked if Rate-Limit header looks good

@psrok1 psrok1 merged commit 9c257b3 into master Feb 26, 2024
12 checks passed
@psrok1 psrok1 deleted the refactor/limits branch February 26, 2024 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant