Skip to content

Latest commit

 

History

History
28 lines (20 loc) · 520 Bytes

README.md

File metadata and controls

28 lines (20 loc) · 520 Bytes

tollbooth_gin

Gin middleware for rate limiting HTTP requests.

Five Minutes Tutorial

package main

import (
    "github.com/didip/tollbooth/v7"
    "github.com/didip/tollbooth_gin/v7"
    "github.com/gin-gonic/gin"
)

func main() {
    r := gin.New()

    // Create a limiter struct.
    limiter := tollbooth.NewLimiter(1, nil)

    r.GET("/", tollbooth_gin.LimitHandler(limiter), func(c *gin.Context) {
        c.String(200, "Hello, world!")
    })

    r.Run(":12345")
}