Update utils.go

This commit is contained in:
thinkerou 2020-05-03 23:42:59 +08:00 committed by GitHub
parent 6bd6454ad1
commit 539a24f2cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)
} }
} }
} }