Skip to content

Commit

Permalink
check json tag then form tag
Browse files Browse the repository at this point in the history
  • Loading branch information
wubin1989 committed Dec 9, 2023
1 parent ddecb95 commit 2b7791b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions framework/rest/form.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package rest

import (
"github.com/go-playground/form/v4"
"github.com/unionj-cloud/go-doudou/v2/toolkit/stringutils"
"net/url"
"reflect"
"strings"
Expand All @@ -12,6 +13,9 @@ var encoder = form.NewEncoder()

func tagNameFunc(fld reflect.StructField) string {
name := fld.Tag.Get("json")
if stringutils.IsEmpty(name) {
name = fld.Tag.Get("form")
}
if commaIndex := strings.Index(name, ","); commaIndex != -1 {
name = name[:commaIndex]
}
Expand Down

0 comments on commit 2b7791b

Please sign in to comment.