custommiddleware

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultCleanupTTL is the default cleanup duration for unused limiters.
	DefaultCleanupTTL = 10 * time.Second
	// DefaultCleanupEvery is the default interval for running the cleanup routine.
	DefaultCleanupEvery = 5 * time.Minute
	// DefaultMaxKeys is the default maximum number of keys to store.
	DefaultMaxKeys = 10000
)

Variables

This section is empty.

Functions

func APIKeyFunc added in v1.9.4

func APIKeyFunc(c *echo.Context) string

func IPKeyFunc added in v1.9.4

func IPKeyFunc(c *echo.Context) string

func IPRestriction added in v1.3.2

func IPRestriction() echo.MiddlewareFunc

func JSONRequestLogger added in v1.11.0

func JSONRequestLogger() echo.MiddlewareFunc

JSONRequestLogger returns middleware that outputs the legacy JSON log format.

func JSONRequestLoggerConfig added in v1.11.0

func JSONRequestLoggerConfig() middleware.RequestLoggerConfig

JSONRequestLoggerConfig returns a request logger config that outputs the legacy JSON log format.

func OptionsMethodSkipper

func OptionsMethodSkipper(c *echo.Context) bool

OptionsMethodSkipper skip when option method requested.

Types

type RateLimitConfig added in v1.9.4

type RateLimitConfig struct {
	Rate         rate.Limit
	Burst        int
	KeyFunc      func(c *echo.Context) string
	ErrorMsg     string
	Skipper      func(c *echo.Context) bool
	CleanupTTL   time.Duration // How long to keep unused limiters
	CleanupEvery time.Duration // How often to run cleanup
	MaxKeys      int           // Maximum number of keys to store (0 = unlimited)
}

type RateLimiter added in v1.9.4

type RateLimiter struct {
	// contains filtered or unexported fields
}

func NewRateLimiter added in v1.9.4

func NewRateLimiter(config RateLimitConfig) *RateLimiter

func (*RateLimiter) Middleware added in v1.9.4

func (rl *RateLimiter) Middleware() echo.MiddlewareFunc

Jump to

Keyboard shortcuts

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