diff --git a/README.md b/README.md index d9d0c70..e13a0d5 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ func main() { // Create a request limiter per handler. lmt := tollbooth.NewLimiter(1, nil) - // New in version >= 7, you must explicitly define how to pick the IP address. + // New in version >= 8, you must explicitly define how to pick the IP address. lmt.SetIPLookup(limiter.IPLookup{ Name: "X-Real-IP", IndexFromRight: 0, @@ -78,7 +78,7 @@ func main() { // every token bucket in it will expire 1 hour after it was initially set. lmt = tollbooth.NewLimiter(1, &limiter.ExpirableOptions{DefaultExpirationTTL: time.Hour}) - // New in version >= 7, you must explicitly define how to pick the IP address. + // New in version >= 8, you must explicitly define how to pick the IP address. // If IP address cannot be found, rate limiter will not be activated. lmt.SetIPLookup(limiter.IPLookup{ // The name of lookup method. @@ -95,7 +95,7 @@ func main() { IndexFromRight: 0, }) - // In version >= 7, lmt.SetIPLookups and lmt.GetIPLookups are removed. + // In version >= 8, lmt.SetIPLookups and lmt.GetIPLookups are removed. // Limit only GET and POST requests. lmt.SetMethods([]string{"GET", "POST"}) @@ -162,7 +162,7 @@ func main() { ```go lmt := tollbooth.NewLimiter(1, nil) - // New in version >= 7, you must explicitly define how to pick the IP address. + // New in version >= 8, you must explicitly define how to pick the IP address. lmt.SetIPLookup(limiter.IPLookup{ Name: "X-Forwarded-For", IndexFromRight: 0, diff --git a/libstring/libstring.go b/libstring/libstring.go index 453f254..0e6b334 100644 --- a/libstring/libstring.go +++ b/libstring/libstring.go @@ -6,7 +6,7 @@ import ( "net/http" "strings" - "github.com/didip/tollbooth/v6/limiter" + "github.com/didip/tollbooth/v7/limiter" ) // StringInSlice finds needle in a slice of strings. diff --git a/tollbooth_test.go b/tollbooth_test.go index b023f4b..e5865df 100644 --- a/tollbooth_test.go +++ b/tollbooth_test.go @@ -564,7 +564,10 @@ func (lm *LockMap) Add(key string, incr int64) { func TestLimitHandlerEmptyHeader(t *testing.T) { lmt := limiter.New(nil).SetMax(1).SetBurst(1) - lmt.SetIPLookups([]string{"X-Real-IP", "RemoteAddr", "X-Forwarded-For"}) + lmt.SetIPLookup(limiter.IPLookup{ + Name: "X-Real-IP", + IndexFromRight: 0, + }) lmt.SetMethods([]string{"POST"}) lmt.SetHeader("user_id", []string{})