feat: 增加接口流量配置中间件
This commit is contained in:
@@ -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
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user