middleware

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIKeyAuth

func APIKeyAuth() gin.HandlerFunc

APIKeyAuth API Key 认证中间件

func BasicAuth

func BasicAuth() gin.HandlerFunc

BasicAuth 基本认证中间件

func ErrorHandler

func ErrorHandler() gin.HandlerFunc

ErrorHandler 处理所有未捕获的路由和错误

func Logger

func Logger() gin.HandlerFunc

Types

type RateLimiter

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

func NewRateLimiter

func NewRateLimiter(redisClient *redis.Client, maxRequests int, duration, banDuration time.Duration) *RateLimiter

func (*RateLimiter) RateLimit

func (rl *RateLimiter) RateLimit() gin.HandlerFunc

func (*RateLimiter) UnbanIP

func (rl *RateLimiter) UnbanIP(ctx context.Context, ip string) error

解封IP的方法(可用于管理API)

Jump to

Keyboard shortcuts

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