Documentation ¶ Index ¶ Variables func CreateToken(claims JWTClaims) (string, error) func JWTAuth() gin.HandlerFunc func RefreshToken(tokenString string) (string, error) type JWTClaims func ParseToken(tokenString string) (*JWTClaims, 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 CreateToken ¶ func CreateToken(claims JWTClaims) (string, error) 创建token func JWTAuth ¶ func JWTAuth() gin.HandlerFunc JWT中间件 func RefreshToken ¶ func RefreshToken(tokenString string) (string, error) 更新token Types ¶ type JWTClaims ¶ type JWTClaims struct { ID interface{} `bson:"_id"` Email string `bson:"email"` //Phone string `bson:"phone"` jwt.StandardClaims } func ParseToken ¶ func ParseToken(tokenString string) (*JWTClaims, error) 解析token Source Files ¶ View all Source files jwt.go Click to show internal directories. Click to hide internal directories.