httpware

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HeaderRateLimitLimit, HeaderRateLimitRemaining, and HeaderRateLimitReset
	// are the recommended return header values from IETF on rate limiting. Reset
	// is in UTC time.
	HeaderRateLimitLimit     = "X-RateLimit-Limit"
	HeaderRateLimitRemaining = "X-RateLimit-Remaining"
	HeaderRateLimitReset     = "X-RateLimit-Reset"

	// HeaderRetryAfter is the header used to indicate when a client should retry
	// requests (when the rate limit expires), in UTC time.
	HeaderRetryAfter = "Retry-After"
)

Variables

This section is empty.

Functions

func GetLanguage

func GetLanguage(r *http.Request) (languages []string)

Types

type Limiter

type Limiter struct {
	Store limiter.Store
	// contains filtered or unexported fields
}

func NewLimiter

func NewLimiter(config models.ConfigHTTP, window time.Duration) *Limiter

func (*Limiter) IsSkipped

func (l *Limiter) IsSkipped(ctx context.Context) bool

func (*Limiter) Key

func (l *Limiter) Key(r *http.Request) string

func (*Limiter) Limit

func (l *Limiter) Limit(next http.Handler) http.Handler

Limit returns the HTTP handler as a middleware. Use Limiter.Skip() to skip the rate limiting logic, and only return the headers.

func (*Limiter) Skip

func (l *Limiter) Skip(next http.Handler) http.Handler

Jump to

Keyboard shortcuts

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