Reputation: 19840
I want to implement a shadowban. Above a certain rate limit, I want to not respond anything to a request.
I couldn't find how to do that in the doc.
It seems setting body = null
will still trigger a response.
How may I prevent koa@2 from answering to a request?
Upvotes: 2
Views: 797
Reputation: 3057
You should be able to do this by setting ctx.respond = false
in your route handler.
Having a look through koa
's source code shows this: https://github.com/koajs/koa/blob/master/lib/application.js#L201
function respond(ctx) {
// allow bypassing koa
if (false === ctx.respond) return;
// ...
Upvotes: 2