add redis
This commit is contained in:
@@ -3,6 +3,7 @@ package context
|
||||
import (
|
||||
"git.trj.tw/golang/go-gallery/modules/apimsg"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gin-gonic/gin/binding"
|
||||
)
|
||||
|
||||
// Context custom patch context
|
||||
@@ -15,16 +16,22 @@ type Context struct {
|
||||
type CustomMiddle func(*Context)
|
||||
|
||||
// PatchContext func
|
||||
func PatchContext(handler CustomMiddle) gin.HandlerFunc {
|
||||
func PatchContext(handler func(*Context)) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
ctx := &Context{
|
||||
Context: c,
|
||||
C: make(map[string]interface{}),
|
||||
}
|
||||
ctx.C = make(map[string]interface{})
|
||||
handler(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
// BindData -
|
||||
func (c *Context) BindData(i interface{}) error {
|
||||
b := binding.Default(c.Request.Method, c.ContentType())
|
||||
return c.ShouldBindWith(i, b)
|
||||
}
|
||||
|
||||
// NotFound response
|
||||
func (c *Context) NotFound(msg interface{}) {
|
||||
obj := apimsg.GetRes("NotFound", msg)
|
||||
|
||||
Reference in New Issue
Block a user