From 66b2085898f2440eb195199a9bd733e3df1eae51 Mon Sep 17 00:00:00 2001 From: zensh Date: Thu, 11 Jun 2020 19:15:15 +0800 Subject: [PATCH] fixed ratelimiter bucket --- pkg/middlewares/canary/canary.go | 2 +- pkg/middlewares/ratelimiter/rate_limiter.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/middlewares/canary/canary.go b/pkg/middlewares/canary/canary.go index 94197bafb4..845d951f47 100644 --- a/pkg/middlewares/canary/canary.go +++ b/pkg/middlewares/canary/canary.go @@ -23,7 +23,7 @@ const ( headerAuth = "Authorization" headerUA = "User-Agent" headerXCanary = "X-Canary" - headerXRequestID = "X-Request-ID" + headerXRequestID = "X-Request-Id" defaultCacheSize = 100000 defaultExpiration = time.Minute * 10 defaultCacheCleanDuration = time.Minute * 20 diff --git a/pkg/middlewares/ratelimiter/rate_limiter.go b/pkg/middlewares/ratelimiter/rate_limiter.go index 3673a10e3e..4bcf345502 100644 --- a/pkg/middlewares/ratelimiter/rate_limiter.go +++ b/pkg/middlewares/ratelimiter/rate_limiter.go @@ -121,7 +121,7 @@ func (rl *rateLimiter) ServeHTTP(w http.ResponseWriter, r *http.Request) { bucket = rlSource.(*rate.Limiter) } else { bucket = rate.NewLimiter(rl.rate, int(rl.burst)) - if err := rl.buckets.Set(source, bucket, int(rl.maxDelay)*10+1); err != nil { + if err := rl.buckets.Set(source, bucket, int(rl.maxDelay/time.Second)*10+1); err != nil { logger.Errorf("could not insert bucket: %v", err) http.Error(w, "could not insert bucket", http.StatusInternalServerError) return