gin/router/register_test.go

48 lines
918 B
Go
Raw Normal View History

2024-07-20 23:39:25 +08:00
// Package router ...
//
// Description : router ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 2024-07-20 23:24
package router
import (
"testing"
"github.com/gin-gonic/gin"
)
type TestController struct{}
func (t *TestController) RouterPrefix() string {
return "/uri/prefix"
}
func (t *TestController) RouterMiddleware() []gin.HandlerFunc {
return []gin.HandlerFunc{
func(ctx *gin.Context) {
},
}
}
2024-07-21 16:51:02 +08:00
func (t *TestController) Uri(ctx *gin.Context, formData *TestForm) (any, error) {
return formData, nil
2024-07-21 16:51:02 +08:00
}
type TestForm struct {
Meta `tag:"测试表单" path:"/a/b/c/d" desc:"测试接口" method:"get" strict:"true"`
Age int `json:"age" form:"age"`
Name string `json:"name" form:"name"`
2024-07-22 11:19:41 +08:00
Test struct {
L string `json:"l"`
} `json:"test" form:"test"`
2024-07-21 16:51:02 +08:00
}
2024-07-20 23:39:25 +08:00
func Test_parseController(t *testing.T) {
type args struct {
controller any
}
Register(8080, &TestController{})
2024-07-20 23:39:25 +08:00
}