mirror of
https://github.com/xinliangnote/go-gin-api.git
synced 2024-04-21 12:31:46 +00:00
15 lines
297 B
Go
15 lines
297 B
Go
package util
|
|
|
|
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
|
|
}
|