mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-18 23:12:17 +08:00
Update utils.go
This commit is contained in:
parent
6bd6454ad1
commit
539a24f2cd
4
utils.go
4
utils.go
@ -14,7 +14,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const bindKey = "_gin-gonic/gin/bindkey"
|
const BindKey = "_gin-gonic/gin/bindkey"
|
||||||
|
|
||||||
// Bind is a helper function for given interface object and returns a Gin middleware.
|
// Bind is a helper function for given interface object and returns a Gin middleware.
|
||||||
func Bind(val interface{}) HandlerFunc {
|
func Bind(val interface{}) HandlerFunc {
|
||||||
@ -29,7 +29,7 @@ func Bind(val interface{}) HandlerFunc {
|
|||||||
return func(c *Context) {
|
return func(c *Context) {
|
||||||
obj := reflect.New(typ).Interface()
|
obj := reflect.New(typ).Interface()
|
||||||
if c.Bind(obj) == nil {
|
if c.Bind(obj) == nil {
|
||||||
c.Set(bindKey, obj)
|
c.Set(BindKey, obj)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user