package main
import (
"fmt"
"net/http"
"time"
"github.com/as/rate"
"github.com/as/rate/httprate"
)
func main() {
lim := rate.New(time.Minute * 5)
http.Handle("/", httprate.HandlerFunc(lim, time.Minute, nil, func(tx http.ResponseWriter, rx *http.Request) {
tx.Write([]byte("welcome to /"))
}))
fmt.Println(http.ListenAndServe(":80", nil))
}
-
Notifications
You must be signed in to change notification settings - Fork 0
A simple task-granular rate limiter based on the passage of time
License
as/rate
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
A simple task-granular rate limiter based on the passage of time
Topics
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published