Documentation
¶
Index ¶
- Constants
- Variables
- func APIOutPut(c *gin.Context, msg string, data interface{})
- func APIOutPutError(c *gin.Context, msg string)
- func AuthErrorOut(c *gin.Context)
- func CSRFMiddleware() gin.HandlerFunc
- func CSRFTokenMiddleware() gin.HandlerFunc
- func FormSetCSRF(r *http.Request) template.HTML
- func GetPostArgs(c *gin.Context, obj interface{}) error
- func Handle(h HandlerFunc) gin.HandlerFunc
- func NewGinServer()
- func OutHtml()
- func SetCSRFTokenMiddleware(key string) gin.HandlerFunc
- type GinCtx
- func (ctx *GinCtx) APIOutPut(data interface{}, msg string)
- func (ctx *GinCtx) APIOutPutError(err error, msg string)
- func (ctx *GinCtx) AuthErrorOut()
- func (ctx *GinCtx) GetParam(key string) string
- func (ctx *GinCtx) GetParamInt(key string) int
- func (ctx *GinCtx) GetParamInt64(key string) int64
- func (ctx *GinCtx) GetPostArgs(obj interface{}) error
- func (ctx *GinCtx) GetQuery(key string) string
- func (ctx *GinCtx) GetQueryInt(key string) int
- func (ctx *GinCtx) GetQueryInt64(key string) int64
- func (ctx *GinCtx) PageList(pg, number, count, size int, urlTemp string) []*Page
- func (ctx *GinCtx) PageListInt(pg, number, count, size int) []int
- type HandlerFunc
- type Page
- type ResponseJson
Constants ¶
View Source
const ( SuccessCode int64 = 0 ErrorCode int64 = 1 AuthErrorCode int64 = 403 )
Variables ¶
View Source
var ( CsrfName = "cToken" CsrfAuthKey = "123456789" )
View Source
var Router *gin.Engine
Functions ¶
func CSRFMiddleware ¶
func CSRFMiddleware() gin.HandlerFunc
CSRFMiddleware use: ginHelper.CsrfName = "CsrfName" ginHelper.CsrfAuthKey = "CsrfAuthKey" Router.Use(ginHelper.CSRFMiddleware())
func CSRFTokenMiddleware ¶
func CSRFTokenMiddleware() gin.HandlerFunc
func FormSetCSRF ¶
FormSetCSRF use:
c.HTML(http.StatusOK, "login.html", gin.H{
"csrf": ginHelper.FormSetCSRF(c.Request),
})
func Handle ¶
func Handle(h HandlerFunc) gin.HandlerFunc
func NewGinServer ¶
func NewGinServer()
func SetCSRFTokenMiddleware ¶
func SetCSRFTokenMiddleware(key string) gin.HandlerFunc
Types ¶
type GinCtx ¶
GinCtx 给gin context 扩展方法
func (*GinCtx) APIOutPutError ¶
func (*GinCtx) GetParamInt ¶
func (*GinCtx) GetParamInt64 ¶
func (*GinCtx) GetQueryInt ¶
func (*GinCtx) GetQueryInt64 ¶
func (*GinCtx) PageListInt ¶
type HandlerFunc ¶
type HandlerFunc func(c *GinCtx)
type ResponseJson ¶
type ResponseJson struct {
Code int64 `json:"code"` // succeed:0 err:1
Msg string `json:"msg"`
Date interface{} `json:"data"`
TimeStamp int64 `json:"timeStamp"`
}
ResponseJson 统一接口输出
Click to show internal directories.
Click to hide internal directories.