package
2.34.1
Repository: https://github.com/skf/go-utility.git
Documentation: pkg.go.dev

# README

Rate limit Middleware

Example usage

Create a webserver that limits the number of requests to 2 requests per minute on "GET /" Complete example can be found here

   func main() {
   	r := mux.NewRouter()
   	r.HandleFunc("/", HomeHandler)
   
   	limiter := ratelimit.CreateLimiter(ratelimit.GetRedisStore("localhost:6379"))
   	limiter.Configure(
   		ratelimit.Request{Method: http.MethodGet, Path: "/"},
   		func(request *http.Request) ([]ratelimit.Limit, error) {
   			return []ratelimit.Limit{{
   				RequestPerMinute: 2,
   				Key:              "/",
   			}}, nil
   
   		})
   	r.Use(limiter.Middleware())
   
   	err := http.ListenAndServe(":8080", r)
   	log.Errorf(err.Error())
   }

# Packages

No description provided by the author
No description provided by the author

# Functions

No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author
No description provided by the author