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

README: add example for returning X-RateLimit-* headers #193

Merged
merged 1 commit into from
Aug 3, 2016

Conversation

ktheory
Copy link
Collaborator

@ktheory ktheory commented Aug 3, 2016

This addresses a use case from #191 of wanting to return rate limit information (especially X-RateLimit-Reset) for well-behaved clients.

Related: #29


headers = {
'X-RateLimit-Limit' => match_data[:limit].to_s,
'X-RateLimit-Remaining' => 0.to_s, # or [match_data[:limit] - match_data[:count], 0].max
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add to_s after max too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tiegz 👍 I can just simplify this as '0'.

@ktheory ktheory merged commit 53699d6 into rack:master Aug 3, 2016
@ktheory ktheory deleted the ratelimit-headers branch August 3, 2016 18:05
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.

2 participants