Documentation ¶
Index ¶
- Variables
- func ACLMiddle() gin.HandlerFunc
- func CacheMiddle(duration time.Duration, key ...string) gin.HandlerFunc
- func InitAuth(service rbac.IRBACService)
- func LogInfoMiddle() gin.HandlerFunc
- func PanicMiddle() gin.HandlerFunc
- func PrometheusMiddle() gin.HandlerFunc
- func RegisterPrometheus()
- func ThrottleMiddle(resourceName string) gin.HandlerFunc
- type AccessctlEntity
- type CustomClaims
- type ThrottleEntity
Constants ¶
This section is empty.
Variables ¶
View Source
var ( CustomerRequestsTotal = prometheus.NewCounterVec( prometheus.CounterOpts{ Name: "custom_http_requests_total", Help: "Total number of HTTP requests.", }, []string{"path", "method", "status"}, ) ThrottleCounter = prometheus.NewCounterVec( prometheus.CounterOpts{ Name: "throttle_counter_total", Help: "Total number of requests that passed the throttle.", }, []string{"resource", "status"}, ) )
全局 Prometheus 指标
View Source
var Auth *auth
定义全局变量
Functions ¶
func CacheMiddle ¶
func CacheMiddle(duration time.Duration, key ...string) gin.HandlerFunc
duration:缓存时长,key:可选参数缓存key
func PrometheusMiddle ¶
func PrometheusMiddle() gin.HandlerFunc
PrometheusMiddleware 记录常规的 HTTP 请求统计数据
func ThrottleMiddle ¶
func ThrottleMiddle(resourceName string) gin.HandlerFunc
Types ¶
type AccessctlEntity ¶ added in v1.8.6
type CustomClaims ¶
type ThrottleEntity ¶
type ThrottleEntity struct { Limiter *rate.Limiter UserId string //用户Id RateLimit int // 每秒令牌生成数 Burst int // 突发容量 WaitTime int // 最大排队等待时间 CustomSet bool // 自定义配置 }
func GetThrottleEntity ¶ added in v1.8.6
func GetThrottleEntity(resourceName string, useDefault bool) *ThrottleEntity
GetThrottleEntity 获取限流实体,确保每个资源名对应的限流实体是持久化的
Source Files ¶
Click to show internal directories.
Click to hide internal directories.