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

X-RateLimit headers #50

Closed
gvc opened this issue Mar 26, 2014 · 2 comments
Closed

X-RateLimit headers #50

gvc opened this issue Mar 26, 2014 · 2 comments

Comments

@gvc
Copy link

gvc commented Mar 26, 2014

I'm building an API with throttling and the API has well educated clients, that can respect the X-RateLimit headers. I haven't found a way to do this in the rack-attack gem. Is there an interest in this feature for throttling? I can develop, but was just wondering if it's desirable to the gem.

Many APIs are using this already:
http://developer.github.com/v3/#rate-limiting
http://developer.vimeo.com/guidelines/rate-limiting
https://dev.twitter.com/docs/rate-limiting/1.1

Looking forward for your feedback.

@ktheory
Copy link
Collaborator

ktheory commented Mar 26, 2014

Good question, @gvc. It's pretty easy to figure out what to put in the X-RateLimit response header by inspecting the annotated environment.

Check out a request's env['rack.attack.throttle_data']. It's a hash of throttles the request matched (but didn't necessarily exceed); and the count, period, and limit of the throttle. It's set here.

@ktheory ktheory closed this as completed Mar 26, 2014
@dapicester
Copy link

@gvc have a look at this: https://github.com/jbyck/rack-attack-rate-limit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants