Browse Source

Optimization

Volodymyr Tkach 2 years ago
parent
commit
7b7dc7f9c7
1 changed files with 5 additions and 3 deletions
  1. 5 3
      utils/http/servauth/servauth.go

+ 5 - 3
utils/http/servauth/servauth.go

@@ -86,9 +86,11 @@ func BasicAuth(handler http.Handler, username, password, realm string) http.Hand
 			}
 
 			// Reset counter
-			reqs = 0
-			mRequests.SetCount(ip, reqs)
-			mRequests.SetTime(ip, time.Now().UTC().Unix())
+			if reqs > 0 {
+				reqs = 0
+				mRequests.SetCount(ip, reqs)
+				mRequests.SetTime(ip, time.Now().UTC().Unix())
+			}
 		}
 
 		handler.ServeHTTP(w, r)