Categorygithub.com/worktimeassistant/gin-limit
modulepackage
0.0.0-20170515221510-61df50ba1ec3
Repository: https://github.com/worktimeassistant/gin-limit.git
Documentation: pkg.go.dev

# README

Rate limiter Build Status GoDoc

Simple rate limiting middleware for Gin. You can set rates per endpoint or on the global router.

Install

go get -u github.com/WorkTimeAssistant/gin-limit

Usage

Limit global or endpoint's router.

package main

import (
	gl github.com/WorkTimeAssistant/gin-limit
	"github.com/gin-gonic/gin"
)

func main() {
	router := gin.Default()
	router.Use(gl.Limit(1000 /* max requests per second */, 20 /* max burst size*/))
	router.GET("/test", gl.Limit(100, 10), /* handler */)
	router.Run()
}

# Functions

Drops (HTTP status 429) the request if the limit is reached.

# Variables

No description provided by the author