mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-05-01 21:10:13 +00:00
fix: Retry-After header now uses actual limiter window
Previously the Retry-After header was hardcoded to "60" seconds regardless of the rate limiter's actual window duration. Now uses the limiter's configured window (e.g., 600 seconds for recovery endpoints, 300 for exports). Related to #579
This commit is contained in:
parent
a0b4a981b8
commit
dc156d097c
1 changed files with 2 additions and 2 deletions
|
|
@ -158,8 +158,8 @@ func UniversalRateLimitMiddleware(next http.Handler) http.Handler {
|
|||
|
||||
// Check rate limit
|
||||
if !limiter.Allow(ip) {
|
||||
// Add retry-after header
|
||||
w.Header().Set("Retry-After", "60")
|
||||
// Add retry-after header matching the limiter's actual window
|
||||
w.Header().Set("Retry-After", strconv.Itoa(int(limiter.window.Seconds())))
|
||||
w.Header().Set("X-RateLimit-Limit", strconv.Itoa(limiter.limit))
|
||||
w.Header().Set("X-RateLimit-Remaining", "0")
|
||||
w.Header().Set("X-RateLimit-Reset", time.Now().Add(limiter.window).Format(time.RFC3339))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue