# 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())
}
# Functions
No description provided by the author