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

Add option to throw error instead of setting body #13

Closed
wants to merge 1 commit into from

Conversation

ruimarinho
Copy link
Contributor

It can be useful to centralize all application errors in a single error handler, but currently this is not possible because the ratelimit middleware automatically handles it. My suggestion, implemented in this PR, is to pass a new option (throw: true) to throw the error instead, allowing a custom error handler to process it.

I considered making this the default option, since this.throw makes it somewhat compatible with koa's built-in error handler. However, this is not the case because all headers are removed from the response, so x-ratelimit-limit, x-ratelimit-remaining and x-ratelimit-reset would be missing from the response.

@fixe
Copy link
Member

fixe commented Mar 30, 2015

What about adding support for specifying headers in koa and making this the default? /cc @dead-horse

@felixfbecker
Copy link

Related koajs/koa#571

@haoxins
Copy link
Member

haoxins commented Mar 23, 2016

@koajs/ratelimit any more advice?

@haoxins
Copy link
Member

haoxins commented Apr 11, 2016

land abf2924

@haoxins haoxins closed this Apr 11, 2016
@haoxins
Copy link
Member

haoxins commented Apr 11, 2016

@ruimarinho koa-ratelimit@2.2.0

@ruimarinho ruimarinho deleted the enhancement/throw branch May 13, 2016 18:19
@ruimarinho ruimarinho restored the enhancement/throw branch May 13, 2016 18:19
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.

4 participants