From 5abd91f9473cc76ece9ccc0a7fd2fc2a3079cba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Fri, 20 Sep 2024 17:34:53 +0800 Subject: [PATCH] =?UTF-8?q?set=20defult=E6=94=AF=E6=8C=81get?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- request/form.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/request/form.go b/request/form.go index 13cb846..3dc09e1 100644 --- a/request/form.go +++ b/request/form.go @@ -50,10 +50,10 @@ func (f *form) Parse(ctx *gin.Context, receiver interface{}) error { method == http.MethodTrace || method == http.MethodConnect || method == http.MethodOptions { - return ctx.ShouldBindQuery(receiver) - } - - if method == http.MethodPost || + if err := ctx.ShouldBindQuery(receiver); nil != err { + return err + } + } else if method == http.MethodPost || method == http.MethodPut || method == http.MethodDelete { if ContentType.IsJson(ctx) { @@ -67,6 +67,8 @@ func (f *form) Parse(ctx *gin.Context, receiver interface{}) error { } else { return errors.New(ctx.ContentType() + " is not support") } + } else { + return errors.New(method + " is not support") } // 设置默认值 defaults.SetDefaults(receiver)