Let's say, for example, I want to rate limit based on the whether the requester is authenticated. I don't believe this is currently possible (obviously correct me if I'm wrong).
I would propose supporting something like this:
import { RateLimiter } from "https://deno.land/x/oak_rate_limit/mod.ts";
const rateLimit = RateLimiter({
store: STORE,
windowMs: 1000,
max: (ctx) => {
if (ctx.request.headers.get("Auth") == "true") {
return 1000;
} else {
return 100;
}
},
headers: true,
message: "Too many requests, please try again later.",
statusCode: 429,
});
app.use(rateLimit);
(I haven't run that through an editor or anything, so no idea if it's actually valid).
I'd be happy to make a pull request to allow something like this, if you think it would be a useful feature.
Let's say, for example, I want to rate limit based on the whether the requester is authenticated. I don't believe this is currently possible (obviously correct me if I'm wrong).
I would propose supporting something like this:
(I haven't run that through an editor or anything, so no idea if it's actually valid).
I'd be happy to make a pull request to allow something like this, if you think it would be a useful feature.