Closed ruimarinho closed 8 years ago
What about adding support for specifying headers
in koa and making this the default? /cc @dead-horse
@koajs/ratelimit any more advice?
land abf2924a0a9873b19432940bbf8c1edcd3cc84a3
@ruimarinho koa-ratelimit@2.2.0
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, sox-ratelimit-limit
,x-ratelimit-remaining
andx-ratelimit-reset
would be missing from the response.