https://github.com/go-http-utils/ratelimit
:no_bicycles:HTTP ratelimit middleware for Go
https://github.com/go-http-utils/ratelimit
Last synced: 5 months ago
JSON representation
:no_bicycles:HTTP ratelimit middleware for Go
- Host: GitHub
- URL: https://github.com/go-http-utils/ratelimit
- Owner: go-http-utils
- License: mit
- Created: 2016-12-08T02:20:02.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-03T12:18:58.000Z (over 9 years ago)
- Last Synced: 2025-10-01T05:32:16.795Z (9 months ago)
- Language: Go
- Homepage: https://godoc.org/github.com/go-http-utils/ratelimit
- Size: 6.84 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ratelimit
[](https://travis-ci.org/go-http-utils/ratelimit)
[](https://coveralls.io/github/go-http-utils/ratelimit?branch=master)
HTTP ratelimit middleware for Go.
## Installation
```
go get -u github.com/go-http-utils/ratelimit
```
## Documentation
API documentation can be found here: https://godoc.org/github.com/go-http-utils/ratelimit
## Usage
```go
import (
"github.com/go-http-utils/ratelimit"
)
```
```go
getIDByReq := func(req *http.Request) string {
return req.RemoteAddr
}
m := http.NewServeMux()
m.HandleFunc("/", func(res http.ResponseWriter, req *http.Request) {
res.WriteHeader(http.StatusOK)
res.Write([]byte("Hello Worlkd"))
})
http.ListenAndServe(":8080", ratelimit.Handler(m, ratelimit.Options{
GetID: getIDByReq,
Duration: 1 * time.Second,
Count: 1000,
}))
```