Skip to content

Commit 1677b6d

Browse files
committed
set headers if we are actually RLing
1 parent 9719e45 commit 1677b6d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

limiter.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ func (l *RateLimiter) OnLimit(w http.ResponseWriter, r *http.Request, key string
7272
currentWindow := time.Now().UTC().Truncate(l.windowLength)
7373
ctx := r.Context()
7474

75-
setHeader(w, l.headers.Reset, fmt.Sprintf("%d", currentWindow.Add(l.windowLength).Unix()))
76-
7775
limit, ok := getRequestLimit(ctx)
7876
if !ok {
7977
limit = l.requestLimit
@@ -86,6 +84,8 @@ func (l *RateLimiter) OnLimit(w http.ResponseWriter, r *http.Request, key string
8684
if limit == -1 {
8785
return false
8886
}
87+
88+
setHeader(w, l.headers.Reset, fmt.Sprintf("%d", currentWindow.Add(l.windowLength).Unix()))
8989
setHeader(w, l.headers.Limit, fmt.Sprintf("%d", limit))
9090

9191
increment, ok := getIncrement(r.Context())

0 commit comments

Comments
 (0)