mirror of
https://github.com/kataras/iris.git
synced 2025-12-23 21:07:03 +00:00
remove experimental-handlers examples, users should visit github.com/iris-contrib/middleware instead, let's not have duplications
Former-commit-id: 72754683d1bcd4325b5fcd9f57c6cb87f1d7337d
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/kataras/iris"
|
||||
|
||||
"github.com/didip/tollbooth"
|
||||
"github.com/iris-contrib/middleware/tollboothic"
|
||||
)
|
||||
|
||||
// $ go get github.com/didip/tollbooth
|
||||
// $ go run main.go
|
||||
|
||||
func main() {
|
||||
app := iris.New()
|
||||
|
||||
limiter := tollbooth.NewLimiter(1, nil)
|
||||
//
|
||||
// or create a limiter with expirable token buckets
|
||||
// This setting means:
|
||||
// create a 1 request/second limiter and
|
||||
// every token bucket in it will expire 1 hour after it was initially set.
|
||||
// limiter := tollbooth.NewLimiter(1, &limiter.ExpirableOptions{DefaultExpirationTTL: time.Hour})
|
||||
|
||||
app.Get("/", tollboothic.LimitHandler(limiter), func(ctx iris.Context) {
|
||||
ctx.HTML("<b>Hello, world!</b>")
|
||||
})
|
||||
|
||||
app.Run(iris.Addr(":8080"))
|
||||
}
|
||||
|
||||
// Read more at: https://github.com/didip/tollbooth
|
||||
Reference in New Issue
Block a user