Echo middleware for rate limiting HTTP requests.
package main
import (
"time"
"github.com/didip/tollbooth"
"github.com/didip/tollbooth_echo"
"github.com/labstack/echo"
"github.com/labstack/echo/engine/standard"
)
func main() {
e := echo.New()
// Create a limiter struct.
limiter := tollbooth.NewLimiter(1, time.Second, nil)
e.Get("/", echo.HandlerFunc(func(c echo.Context) error {
return c.String("Hello, World!", 200)
}), tollbooth_echo.LimitHandler(limiter))
e.Run(standard.New(":4444"))
}