Browse Source

pass bind func as parse param

eg:
request.ParseSuccess(ctx, cp, (*gin.Context).ShouldBindQuery)
or
request.ParseSuccess(ctx, cp, (*gin.Context).ShouldBindJSON)
Wendell Sun 6 years ago
parent
commit
202e39f52d
1 changed files with 2 additions and 2 deletions
  1. 2
    2
      request/request.go

+ 2
- 2
request/request.go View File

@@ -12,9 +12,9 @@ type Checker interface {
12 12
 	Check() error
13 13
 }
14 14
 
15
-func ParseSuccess(ctx *gin.Context, r interface{}, fs ...func() error) bool {
15
+func ParseSuccess(ctx *gin.Context, r interface{}, bindFunc func(*gin.Context, interface{}) error, fs ...func() error) bool {
16 16
 	if r != nil {
17
-		if Fail(ctx, http.StatusBadRequest, ctx.ShouldBind(r)) {
17
+		if Fail(ctx, http.StatusBadRequest, bindFunc(ctx, r)) {
18 18
 			return false
19 19
 		}
20 20