Skip to content

Commit

Permalink
fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
minghinmatthewlam committed Oct 11, 2024
1 parent f9bd154 commit b8bd532
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions internal/server/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,25 @@ func (l *Limiter) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.Ha
return
}

clintIP := getClientIPFromRequest(l.proxyCount, r)
clientIP := getClientIPFromRequest(l.proxyCount, r)
l.mutex.Lock()
if l.limitByKey(w, address) || l.limitByKey(w, clintIP) {
if l.limitByKey(w, address) || l.limitByKey(w, clientIP) {
l.mutex.Unlock()
return
}
l.cache.SetWithTTL(address, true, l.ttl)
l.cache.SetWithTTL(clintIP, true, l.ttl)
l.cache.SetWithTTL(clientIP, true, l.ttl)
l.mutex.Unlock()

next.ServeHTTP(w, r)
if w.(negroni.ResponseWriter).Status() != http.StatusOK {
l.cache.Remove(address)
l.cache.Remove(clintIP)
l.cache.Remove(clientIP)
return
}
log.WithFields(log.Fields{
"address": address,
"clientIP": clintIP,
"clientIP": clientIP,
}).Info("Maximum request limit has been reached")
}

Expand Down

0 comments on commit b8bd532

Please sign in to comment.