diff --git a/limiter/limiter.go b/limiter/limiter.go index c64a7f2..5561e6c 100644 --- a/limiter/limiter.go +++ b/limiter/limiter.go @@ -261,9 +261,9 @@ func (l *Limiter) SetOnLimitReached(fn func(w http.ResponseWriter, r *http.Reque // ExecOnLimitReached is thread-safe way of executing after-rejection function when limit is reached. func (l *Limiter) ExecOnLimitReached(w http.ResponseWriter, r *http.Request) { l.RLock() - defer l.RUnlock() - fn := l.onLimitReached + l.RUnlock() + if fn != nil { fn(w, r) }