完成基础反射调用接口 + 数据响应

This commit is contained in:
2025-02-07 16:57:15 +08:00
parent 77ea723e86
commit e95061a1a8
6 changed files with 44 additions and 46 deletions

View File

@ -15,24 +15,13 @@ import (
type TestController struct{}
func (t *TestController) RouterPrefix() string {
return "/uri/prefix"
}
func (t *TestController) RouterMiddleware() []gin.HandlerFunc {
return []gin.HandlerFunc{
func(ctx *gin.Context) {
},
}
}
func (t *TestController) Uri(ctx *gin.Context, formData *TestForm) (any, error) {
func (t TestController) Logic(ctx *gin.Context, formData *TestForm) (any, error) {
return formData, nil
}
type TestForm struct {
Meta `tag:"测试表单" path:"/a/b/c/d" desc:"测试接口" method:"get" strict:"true"`
Age int `json:"age" form:"age"`
Age int `json:"age" form:"age" binding:"min=20"`
Name string `json:"name" form:"name"`
Test *Test `json:"test" form:"test"`
Num *int64 `json:"num" form:"num"`
@ -42,8 +31,7 @@ type Test struct {
}
func Test_parseController(t *testing.T) {
type args struct {
controller any
}
Register(8080, &TestController{})
r := gin.Default()
Group(r, "test", nil, TestController{})
r.Run(":8080")
}