new project

This commit is contained in:
Jay
2018-12-24 14:34:13 +08:00
commit 9d9fe262f4
544 changed files with 303269 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
package context
import "github.com/gin-gonic/gin"
import "github.com/gin-gonic/gin/binding"
// Context - custom http context
type Context struct {
*gin.Context
}
// CustomMiddle -
type CustomMiddle func(*Context)
// PatchCtx - change custom middle to gin middle
func PatchCtx(handler CustomMiddle) gin.HandlerFunc {
return func(c *gin.Context) {
ctx := &Context{
Context: c,
}
handler(ctx)
}
}
// BindData - binding data
func (c *Context) BindData(i interface{}) error {
b := binding.Default(c.Request.Method, c.ContentType())
return c.ShouldBindWith(i, b)
}
// CustomRes -
func (c *Context) CustomRes(status int, msg interface{}) {
c.AbortWithStatusJSON(status, msg)
}