middleware

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultKeyFunc

func DefaultKeyFunc(c echo.Context) string

DefaultKeyFunc 默认的限流键生成函数

func UserKeyFunc

func UserKeyFunc(c echo.Context) string

UserKeyFunc 基于用户ID的限流键生成函数

Types

type RateLimitConfig

type RateLimitConfig struct {
	Requests int                         // 请求次数
	Window   time.Duration               // 时间窗口
	KeyFunc  func(c echo.Context) string // 限流键生成函数
}

RateLimitConfig 限流配置

type RateLimiter

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

RateLimiter 限流器

func NewRateLimiter

func NewRateLimiter(redis *redis.Client) *RateLimiter

NewRateLimiter 创建限流器

func (*RateLimiter) RateLimit

func (rl *RateLimiter) RateLimit(config RateLimitConfig) echo.MiddlewareFunc

RateLimit 限流中间件

Jump to

Keyboard shortcuts

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