middleware

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 28 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

Functions

func AdminAuth

func AdminAuth() func(c *gin.Context)

func CORS

func CORS() gin.HandlerFunc

func Cache

func Cache() func(c *gin.Context)

func CriticalRateLimit

func CriticalRateLimit() func(c *gin.Context)

func Distribute

func Distribute() func(c *gin.Context)

func DownloadRateLimit

func DownloadRateLimit() func(c *gin.Context)

func GlobalAPIRateLimit

func GlobalAPIRateLimit() func(c *gin.Context)

func GlobalWebRateLimit

func GlobalWebRateLimit() func(c *gin.Context)

func GzipDecodeMiddleware

func GzipDecodeMiddleware() gin.HandlerFunc

func Language

func Language() gin.HandlerFunc

func RelayPanicRecover

func RelayPanicRecover() gin.HandlerFunc

func RequestId

func RequestId() func(c *gin.Context)

func RootAuth

func RootAuth() func(c *gin.Context)

func SelectChannel

func SelectChannel(ctx context.Context, group, requestModel string, lastFailedChannelId int, userId int) (*model.Channel, string, error)

func SetUpLogger

func SetUpLogger(server *gin.Engine)

func SetupContextForSelectedChannel

func SetupContextForSelectedChannel(c *gin.Context, channel *model.Channel, modelName string)

func TokenAuth

func TokenAuth() func(c *gin.Context)

func TokenModelMapping

func TokenModelMapping() func(c *gin.Context)

TokenModelMapping 根据 token 的 ModelMapping 配置,把 ctxkey.RequestModel 映射为目标模型名 只修改 ctxkey.RequestModel,不修改原始请求体 token 的 ModelMapping 字符串由 TokenAuth 中间件预先解析并放入 context 后续的 Distribute 中间件会基于映射后的 RequestModel 选择渠道 后续渠道级的模型映射依然按原有逻辑执行

func TurnstileCheck

func TurnstileCheck() gin.HandlerFunc

func UploadRateLimit

func UploadRateLimit() func(c *gin.Context)

func UserAuth

func UserAuth() func(c *gin.Context)

Types

type AffinityManager

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

func NewAffinityManager

func NewAffinityManager(seconds int) *AffinityManager

func (*AffinityManager) Get

func (am *AffinityManager) Get(userId int, model string) (channelId int, ok bool)

func (*AffinityManager) Remove

func (am *AffinityManager) Remove(userId int, model string)

func (*AffinityManager) Set

func (am *AffinityManager) Set(userId int, model string, channelId int)

type CooldownManager

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

func NewCooldownManager

func NewCooldownManager(seconds int) *CooldownManager

func (*CooldownManager) IsCoolingDown

func (cm *CooldownManager) IsCoolingDown(channelId int) bool

func (*CooldownManager) Put

func (cm *CooldownManager) Put(channelId int)

func (*CooldownManager) Reset

func (cm *CooldownManager) Reset(channelId int)

type ModelRequest

type ModelRequest struct {
	Model string `json:"model" form:"model"`
}

Jump to

Keyboard shortcuts

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