完成基础反射调用接口 + 数据响应
This commit is contained in:
@ -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")
|
||||
}
|
||||
|
Reference in New Issue
Block a user