limit

package
v1.14.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PerDay

func PerDay(maxAttempts int) http.Limit

func PerDays

func PerDays(decayDays, maxAttempts int) http.Limit

func PerHour

func PerHour(maxAttempts int) http.Limit

func PerHours

func PerHours(decayHours, maxAttempts int) http.Limit

func PerMinute

func PerMinute(maxAttempts int) http.Limit

func PerMinutes

func PerMinutes(decayMinutes, maxAttempts int) http.Limit

Types

type Limit

type Limit struct {
	// The rate limit signature key.
	Key string
	// The maximum number of attempts allowed within the given number of minutes.
	MaxAttempts int
	// The number of minutes until the rate limit is reset.
	DecayMinutes int
	// The response generator callback.
	ResponseCallback func(ctx http.Context)
}

func NewLimit

func NewLimit(maxAttempts, decayMinutes int) *Limit

func (*Limit) By

func (r *Limit) By(key string) http.Limit

func (*Limit) Response

func (r *Limit) Response(callable func(ctx http.Context)) http.Limit

Jump to

Keyboard shortcuts

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