diff --git a/request/form.go b/request/form.go index bfae8ae..7306c04 100644 --- a/request/form.go +++ b/request/form.go @@ -36,21 +36,6 @@ type form struct { // // Date : 00:34 2022/7/3 func (f *form) Parse(ctx *gin.Context, receiver interface{}) error { - var validateFunc = func(parseErr error) error { - if nil != parseErr { - return parseErr - } - receiverIsStruct := false - switch receiver.(type) { - case struct{}: - receiverIsStruct = true - } - if !receiverIsStruct { - // 不是结构体,不验证表单 - return nil - } - return f.checkInstance.Struct(receiver) - } requestBody, _ := ioutil.ReadAll(ctx.Request.Body) // 请求信息写入上下文 @@ -63,18 +48,18 @@ func (f *form) Parse(ctx *gin.Context, receiver interface{}) error { method == http.MethodTrace || method == http.MethodConnect || method == http.MethodOptions { - return validateFunc(ctx.ShouldBindQuery(receiver)) + return ctx.ShouldBindQuery(receiver) } if method == http.MethodPost || method == http.MethodPut || method == http.MethodDelete { if ContentType.IsJson(ctx) { - return validateFunc(ctx.ShouldBindJSON(receiver)) + return ctx.ShouldBindJSON(receiver) } if ContentType.IsFormURLEncoded(ctx) { - return validateFunc(ctx.ShouldBind(receiver)) + return ctx.ShouldBind(receiver) } return errors.New(ctx.ContentType() + " is not support")