Documentation ¶ Index ¶ Variables func Auth() gin.HandlerFunc func GenerateToken(claims CustomClaims) (string, error) type CustomClaims func ParseToken(token string) (*CustomClaims, error) Constants ¶ This section is empty. Variables ¶ View Source var ( TokenExpired error = errors.New("Token is expired") TokenNotValidYet error = errors.New("Token not active yet") TokenMalformed error = errors.New("That's not even a token") TokenInvalid error = errors.New("Couldn't handle this token:") ) Functions ¶ func Auth ¶ func Auth() gin.HandlerFunc Auth 中间件,检查token func GenerateToken ¶ func GenerateToken(claims CustomClaims) (string, error) 生成token Types ¶ type CustomClaims ¶ type CustomClaims struct { Id uint64 `json:"id"` Username string `json:"username"` Guard string `json:"guard"` jwt.StandardClaims } func ParseToken ¶ func ParseToken(token string) (*CustomClaims, error) 解析token Source Files ¶ View all Source files auth.go Click to show internal directories. Click to hide internal directories.