Skip to content

Commit f7a8bb2

Browse files
committed
let basecontroller binding could bind multiple tim
gin-gonic/gin#1341 Signed-off-by: Toby Yan <me@tobyan.com>
1 parent 48ff873 commit f7a8bb2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

http/controller/base_controller.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package controller
22

33
import (
44
"github.com/gin-gonic/gin"
5+
"github.com/gin-gonic/gin/binding"
56
"gopkg.in/go-playground/validator.v9"
67
"net/http"
78
)
@@ -13,7 +14,7 @@ type Controller interface {
1314
type BaseController struct{}
1415

1516
func (bc *BaseController) Validate(c *gin.Context, _validator interface{}) bool {
16-
if err := c.ShouldBindJSON(_validator); err != nil {
17+
if err := c.ShouldBindWith(_validator, binding.JSON); err != nil {
1718

1819
_ = err.(validator.ValidationErrors)
1920
//@todo translate

0 commit comments

Comments
 (0)