Iris middleware for rate limiting HTTP requests.
package main
import (
"time"
"github.com/didip/tollbooth"
"github.com/didip/tollbooth_iris"
"gopkg.in/kataras/iris.v6"
"gopkg.in/kataras/iris.v6/adaptors/httprouter"
)
func main() {
app := iris.New()
app.Adapt( httprouter.New() )
// Create a limiter struct.
limiter := tollbooth.NewLimiter(1, nil)
app.Get("/", tollbooth_iris.LimitHandler(limiter), func(ctx *iris.Context) {
ctx.WriteString("Hello, world!")
})
app.Listen(":8080")
}