Documentation ¶
Index ¶
- Constants
- Variables
- func BindAndValid(c *gin.Context, form interface{}) error
- func CheckUserToken() gin.HandlerFunc
- func Cors() gin.HandlerFunc
- func GenerateToken(username string, uid int) (string, error)
- func GetMsg(code int) string
- func GetRequestId(ctx *gin.Context) (requestId string)
- func JsonResponse(ctx *gin.Context, httpCode, retCode int, data interface{})
- func Metadata(debug bool) gin.HandlerFunc
- func ProtoBufResponse(ctx *gin.Context, httpCode int, data interface{})
- func RateLimit(maxConcurrent int) gin.HandlerFunc
- type Claims
Constants ¶
View Source
const ( SUCCESS = 200 InvalidParams = 400 Unknown = 0000 ERROR = 500 ErrorTokenEmpty = 4002 ErrorTokenInvalid = 4003 ErrorTokenExpire = 4004 ErrorUserNotExist = 4005 TooManyRequests = 4006 )
Variables ¶
View Source
var MsgFlags = map[int]string{
SUCCESS: "ok",
ERROR: "服务器出错",
Unknown: "未知",
TooManyRequests: "请求太多,稍后再试",
InvalidParams: "请求参数错误",
ErrorTokenEmpty: "用户token为空",
ErrorTokenInvalid: "用户token无效",
ErrorTokenExpire: "用户token过期",
ErrorUserNotExist: "用户不存在",
}
Functions ¶
func BindAndValid ¶
func CheckUserToken ¶
func CheckUserToken() gin.HandlerFunc
func Cors ¶
func Cors() gin.HandlerFunc
func GetRequestId ¶ added in v1.5.10
func JsonResponse ¶
func Metadata ¶ added in v1.5.10
func Metadata(debug bool) gin.HandlerFunc
func ProtoBufResponse ¶
func RateLimit ¶ added in v1.5.13
func RateLimit(maxConcurrent int) gin.HandlerFunc
Types ¶
Click to show internal directories.
Click to hide internal directories.