Files
echo-ratelimit/README.md
2026-04-18 05:28:10 -06:00

47 lines
738 B
Markdown

# echo-ratelimit
Small in-memory rate-limiting middleware for [Echo](https://github.com/labstack/echo), keyed by client IP.
## Install
```bash
go get git.carlpearson.net/cwpearson/echo-ratelimit@latest
```
## Usage
```go
package main
import (
"net/http"
"time"
"github.com/labstack/echo/v4"
ratelimit "git.carlpearson.net/cwpearson/echo-ratelimit"
)
func main() {
e := echo.New()
e.Use(ratelimit.Middleware(60, time.Minute))
e.GET("/", func(c echo.Context) error {
return c.String(http.StatusOK, "ok")
})
e.Logger.Fatal(e.Start(":8080"))
}
```
## Custom Configuration
```go
e.Use(ratelimit.WithConfig(ratelimit.Config{
Limit: 10,
Window: time.Minute,
}))
```
Rate-limit headers are emitted by default.