set defult支持get

This commit is contained in:
白茶清欢 2024-09-20 17:34:53 +08:00
parent 4f1e0e2649
commit 5abd91f947

View File

@ -50,10 +50,10 @@ func (f *form) Parse(ctx *gin.Context, receiver interface{}) error {
method == http.MethodTrace || method == http.MethodTrace ||
method == http.MethodConnect || method == http.MethodConnect ||
method == http.MethodOptions { method == http.MethodOptions {
return ctx.ShouldBindQuery(receiver) if err := ctx.ShouldBindQuery(receiver); nil != err {
} return err
}
if method == http.MethodPost || } else if method == http.MethodPost ||
method == http.MethodPut || method == http.MethodPut ||
method == http.MethodDelete { method == http.MethodDelete {
if ContentType.IsJson(ctx) { if ContentType.IsJson(ctx) {
@ -67,6 +67,8 @@ func (f *form) Parse(ctx *gin.Context, receiver interface{}) error {
} else { } else {
return errors.New(ctx.ContentType() + " is not support") return errors.New(ctx.ContentType() + " is not support")
} }
} else {
return errors.New(method + " is not support")
} }
// 设置默认值 // 设置默认值
defaults.SetDefaults(receiver) defaults.SetDefaults(receiver)