feat: 增加接口流量配置中间件

This commit is contained in:
2026-01-04 15:28:11 +08:00
parent 3788d2b4b6
commit ded502746c
13 changed files with 215 additions and 79 deletions

View File

@@ -10,6 +10,7 @@ package router
import (
"testing"
"git.zhangdeman.cn/zhangdeman/rate_limit"
"github.com/gin-gonic/gin"
)
@@ -18,13 +19,13 @@ type testCommon struct {
}
type testForm struct {
Meta `json:"-" method:"get" path:"test"`
Meta `json:"-" method:"get" path:"test" rate-limit:"1/5/60"`
testCommon
Name string `json:"name"`
}
func TestNewServer(t *testing.T) {
s := NewServer(9087)
s := NewServer(9087, WithRateLimitInstance(rate_limit.MemoryClient))
s.AddCommonParamRule("UserID", func(ctx *gin.Context) (any, error) {
return uint(123456), nil
})