add redis

This commit is contained in:
Jay
2018-04-18 14:16:29 +08:00
parent 4fd4c7018e
commit 6419162471
48 changed files with 9952 additions and 14 deletions
+9 -2
View File
@@ -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)