Categorygithub.com/didip/tollbooth_gin
repositorypackage
0.0.0-20250404214326-bb1a1fc0384e
Repository: https://github.com/didip/tollbooth_gin.git
Documentation: pkg.go.dev

# README

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"
    "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")
}