You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Rate limit middleware doesn't set headers or provide metadata via interface. #2961
Similar rate limit middleware like https://github.com/go-chi/httprate handles automatically setting appropriate X-Rate-Limit-* and Retry-After headers on a rate limit event which this middleware does not. This is compounded by the RateLimiterStore interface not providing a mechanism for returning metadata to set them manually either.
Activity
aldas commentedon Apr 30, 2026
we could add logic that if store (
middleware.RateLimiterStore) that is given implements this optional interfaceit will be called instead of
RateLimiterStore.Allow(identifier string) (bool, error)and it will also set the headers.We use this kind of logic in Proxy middleware in
v4about metadata. I do not know if golang.org/x/time/rate has that kind of information
Maybe for
Retry-Afterheader the https://pkg.go.dev/golang.org/x/time/rate#Limiter.ReserveNr.Delay()can be used?aldas commentedon Apr 30, 2026
it more or less looks like a pretty major rewrite with ugly workarounds when existing API will not be changed and will continue to be supported.
feat(middleware): set X-RateLimit-* / Retry-After from built-in store (…
feat(middleware): optional RateLimiterStoreContext for response heade…