middlewares

package
v2.41.1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2026 License: CC0-1.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JWTAuth

func JWTAuth(next http.Handler) http.Handler

func NewRateLimiter added in v2.41.0

func NewRateLimiter(opts ...RateLimiterOption) func(http.Handler) http.Handler

NewRateLimiter returns an http.Handler middleware that rate-limits requests using a token-bucket algorithm per bucket key (default = IP address).

func StaticAuth added in v2.6.0

func StaticAuth(next http.Handler) http.Handler

Types

type JWTConfig

type JWTConfig struct {
}

type KeyExtractor added in v2.41.0

type KeyExtractor func(r *http.Request) string

KeyExtractor returns the rate-limit bucket key for a request.

type RateLimiterOption added in v2.41.0

type RateLimiterOption func(*rateLimiter)

RateLimiterOption configures the rate limiter.

func WithKeyExtractor added in v2.41.0

func WithKeyExtractor(fn KeyExtractor) RateLimiterOption

WithKeyExtractor replaces the default IP-based key extractor.

func WithMessage added in v2.41.0

func WithMessage(msg, code string) RateLimiterOption

WithMessage sets the error message and error code returned on limit.

func WithRate added in v2.41.0

func WithRate(rps float64, burst int) RateLimiterOption

WithRate sets the request-per-second limit and burst size.

func WithSkipPaths added in v2.41.0

func WithSkipPaths(paths ...string) RateLimiterOption

WithSkipPaths disables rate limiting for the given exact paths.

Jump to

Keyboard shortcuts

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