add line webhook router

This commit is contained in:
Jay
2018-12-24 17:34:24 +08:00
parent 9d9fe262f4
commit 4726070ea5
19 changed files with 969 additions and 142 deletions
+41 -2
View File
@@ -1,7 +1,10 @@
package context
import "github.com/gin-gonic/gin"
import "github.com/gin-gonic/gin/binding"
import (
"git.trj.tw/golang/mtgbot/modules/apimsg"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
)
// Context - custom http context
type Context struct {
@@ -31,3 +34,39 @@ func (c *Context) BindData(i interface{}) error {
func (c *Context) CustomRes(status int, msg interface{}) {
c.AbortWithStatusJSON(status, msg)
}
// LoginFirst -
func (c *Context) LoginFirst(msg interface{}) {
obj := apimsg.GetRes("LoginFirst", msg)
c.AbortWithStatusJSON(obj.Status, obj.Obj)
}
// NotFound -
func (c *Context) NotFound(msg interface{}) {
obj := apimsg.GetRes("NotFound", msg)
c.AbortWithStatusJSON(obj.Status, obj.Obj)
}
// DataFormat -
func (c *Context) DataFormat(msg interface{}) {
obj := apimsg.GetRes("DataFormat", msg)
c.AbortWithStatusJSON(obj.Status, obj.Obj)
}
// Forbidden -
func (c *Context) Forbidden(msg interface{}) {
obj := apimsg.GetRes("Forbidden", msg)
c.AbortWithStatusJSON(obj.Status, obj.Obj)
}
// Success -
func (c *Context) Success(msg interface{}) {
obj := apimsg.GetRes("Success", msg)
c.AbortWithStatusJSON(obj.Status, obj.Obj)
}
// ServerError -
func (c *Context) ServerError(msg interface{}) {
obj := apimsg.GetRes("InternalError", msg)
c.AbortWithStatusJSON(obj.Status, obj.Obj)
}