StevenThuriot / express-rate-limiter

Rate limiter middleware for express applications
https://www.npmjs.org/package/express-rate-limiter
MIT License
5 stars 4 forks source link

Response #14

Open Kopfy opened 8 years ago

Kopfy commented 8 years ago

It would be great enhancement to be able to define a custom function which is called when rate limit is exceeded, instead of being limited to: if (shouldLimit) { res.status(429).send('Rate limit exceeded'); return; }

For example, when using a Swagger for building APIs and want that they produce application/json the res.status(429).send('Rate limit exceeded'); returns error.

Would it be possible to add such enhancement, to be able to respond rate limit exceeded in different format, e.g. in JSON such as res.status(429).json({message: 'Rate limit exceeded'}); ?

StevenThuriot commented 8 years ago

Hi Kopfy,

Good idea! I'll be happy to merge a pull request.