limiter

package module
v0.0.0-...-f1b66d2 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

README

go-http-rate-limiter

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type GeneralLimitConfiguration

type GeneralLimitConfiguration struct {
	LimitConfiguration
	EndpointsConfigurations map[string]LimitConfiguration
}

type LimitConfiguration

type LimitConfiguration struct {
	RequestLimit uint32        `json:"limit"`
	Duration     time.Duration `json:"duration"`
}

type Limiter

type Limiter interface {
	LimitHandler(next http.Handler) http.Handler
	CheckLimitFromRequest(r *http.Request) error
}

func CreateRedisRateLimiter

func CreateRedisRateLimiter(ctx context.Context, name string, r *redis.Client, configurations map[uint32]GeneralLimitConfiguration,
	getKeyTypeFunc func(r *http.Request) (string, uint32)) Limiter

Jump to

Keyboard shortcuts

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