https://github.com/dammy001/tollbooth_buffalo
https://github.com/dammy001/tollbooth_buffalo
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/dammy001/tollbooth_buffalo
- Owner: dammy001
- License: mit
- Created: 2023-11-28T15:56:12.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-02T08:43:31.000Z (5 months ago)
- Last Synced: 2025-02-14T10:30:45.873Z (3 months ago)
- Language: Go
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tollbooth_buffalo
[Buffalo](https://gobuffalo.io/) middleware for rate limiting HTTP requests.
## Usage
```go
import (
"github.com/didip/tollbooth/v7"
"github.com/didip/tollbooth/v7/limiter"
"github.com/gobuffalo/envy"
)var ENV = envy.Get("GO_ENV", "development")
func App() *buffalo.App {
appOnce.Do(func() {
app = buffalo.New(buffalo.Options{
Env: ENV
})lmt := tollbooth.NewLimiter(500, &limiter.ExpirableOptions{DefaultExpirationTTL: time.Minute})
lmt.SetMethods([]string{"GET", "POST", "PUT", "DELETE"}).SetIPLookups([]string{"X-Forwarded-For", "X-Authorization", "RemoteAddr", "X-Real-IP"})
lmt.SetMessage("Rate Limit Exceeded.").SetMessageContentType("application/json; charset=utf-8")app.Use(middlewares.RateLimitMiddleware(lmt))
app.GET("/", HomeHandler)
})return app
}
```