middleware

package
v0.0.0-...-d00b715 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApiCacheKeyPrefix = "api_cache:"
)

Variables

This section is empty.

Functions

func CORSMiddleware

func CORSMiddleware() gin.HandlerFunc

func JwtAuthMiddleware

func JwtAuthMiddleware(secret string, cache *cache.RedisCache) gin.HandlerFunc

func New

func New(config Config) gin.HandlerFunc

func NewAPICacheMiddleware

func NewAPICacheMiddleware(cache *cache.RistrettoCache) func(timeout time.Duration) gin.HandlerFunc

NewAPICacheMiddleware 创建一个 API 缓存中间件 用于缓存 API 请求结果 以 uri + method + reqBody 作为 key 还没有自测 慎用 还需要考虑不同用户的请求 以及数据一致性问题

func PrometheusMiddleware

func PrometheusMiddleware() gin.HandlerFunc

func RateLimitMiddleware

func RateLimitMiddleware(env *bootstrap.Env) gin.HandlerFunc

Types

type Config

type Config struct {
	Namespace  string
	Subsystem  string
	Name       string
	Help       string
	InstanceID string
}

func DefaultConfig

func DefaultConfig() Config

Jump to

Keyboard shortcuts

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