That way you could also properly display all the right HTTP headers. With my solution, when the second-limit blocks the request, the response doesn't include headers about the hourly or daily limits.
My apologies in advance if I've massively over-complicated my solution.
I want to rate limit my API's login endpoint thusly: max 1 request per second, max 5 requests per hour, max 10 requests per day.
I have implemented it like this using your middleware:
I think it would be practical to add the function
limiter.NewMultipleRates
(or similar) to allow this:That way you could also properly display all the right HTTP headers. With my solution, when the second-limit blocks the request, the response doesn't include headers about the hourly or daily limits.
My apologies in advance if I've massively over-complicated my solution.