Versions in this module Expand all Collapse all v0 v0.1.0 Oct 16, 2026 Changes in this version + const DefaultWarningHeader + const WarningMalformed + var ErrEmptyPrefix = errors.New("a capability prefix cannot be empty") + var ErrInvalidRate = errors.New("resolver returned an invalid rate") + var ErrMalformedRate = errors.New("malformed rate") + var ErrNoPrefixes = errors.New("at least one capability prefix is required") + type Decision struct + Allowed bool + Err error + Limit Rate + Limits []Rate + Reason Reason + RetryAfter time.Duration + Warnings []Warning + type Extractor func(*http.Request) (principal string, capabilities []string) + type Limiter struct + func New(opts ...Option) (*Limiter, error) + func (l *Limiter) Check(ctx context.Context, principal string, capabilities []string) Decision + type Middleware struct + Extract Extractor + Limiter *Limiter + Observe func(*http.Request, Decision) + OmitWarnings bool + WarningHeader string + func (m Middleware) Wrap(next http.Handler) http.Handler + type Option interface + func WithPrefixes(prefixes ...string) Option + func WithResolver(r Resolver) Option + type Rate struct + Count int + Window time.Duration + func DefaultResolver(_ context.Context, _ string, provided []Rate) ([]Rate, error) + func ParseRate(s string) (Rate, error) + func (r Rate) IsZero() bool + func (r Rate) String() string + type Reason int + const Denied + const None + const RateExceeded + func (r Reason) String() string + type Resolver func(ctx context.Context, principal string, provided []Rate) ([]Rate, error) + type Warning struct + Params [][2]string + Reason string + func (w Warning) String() string