ratelimit

package
v1.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2024 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRateLimitExceed = errors.New("rate limit exceeded")

Functions

func RateLimit

func RateLimit(opts ...Option) gin.HandlerFunc

RateLimit returns a new limiter handler with options

Types

type Limiter

type Limiter interface {
	Allow(ctx *gin.Context) (func(), error)
}

Limiter limits rate of requests for server

type Option

type Option func(options *Options)

func WithErrorHandler

func WithErrorHandler(errorHandler func(ctx *gin.Context, err error)) Option

func WithLimiter

func WithLimiter(limiter Limiter) Option

type Options

type Options struct {
	Limiter      Limiter
	ErrorHandler func(ctx *gin.Context, err error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL