go-chi / httprate

net/http rate limiter middleware
MIT License
270 stars 18 forks source link

Add custom handling function #5

Closed yaronius closed 3 years ago

yaronius commented 3 years ago

This closes https://github.com/go-chi/httprate/issues/4

yaronius commented 3 years ago

Hi @pkieltyka! Do you have any feedback on this?

yaronius commented 3 years ago

Any feedback, please?

pkieltyka commented 3 years ago

hi @yaronius -- the main addition via this PR is to add a "OnLimitFunc" handler which allows you to change a response body for rate-limited requests. This makes sense to me actually and a nice addition.

yaronius commented 3 years ago

Hi @pkieltyka Thank you for the feedback, I'll update the PR and re-request your review then

yaronius commented 3 years ago

I updated the PR with breaking backwards compatibility but using the options pattern which should make further improvements much easier.

pkieltyka commented 3 years ago

beautifully done! do you mind also updating the README to update the example in there, and ensure _example/ is updated + runs as well?

I will merge after that

yaronius commented 3 years ago

I updated the README and examples, checked that the example code works like a charm