Files
go-gin-api/app/util/bind/bind.go
T
2019-11-04 19:25:10 +08:00

15 lines
297 B
Go

package bind
import (
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
)
func Bind(s interface{}, c *gin.Context) (interface{}, error) {
b := binding.Default(c.Request.Method, c.ContentType())
if err := c.ShouldBindWith(s, b); err != nil {
return nil, err
}
return s, nil
}