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