Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( TokenExpired error = errors.New("token已过期,请重新登录") TokenNotValidYet error = errors.New("token无效,请重新登录") TokenMalformed error = errors.New("token不正确,请重新登录") TokenInvalid error = errors.New("这不是一个token,请重新登录") )
定义错误
Functions ¶
Types ¶
type JWT ¶
type JWT struct { // 秘钥,用以加密 JWT,读取配置信息 app.key SignKey []byte // 刷新 Token 的最大过期时间 MaxRefresh time.Duration }
func (*JWT) CreateToken ¶
func (jwt *JWT) CreateToken(claims JWTCustomClaims) (string, error)
CreateToken 生成token
func (*JWT) ParseToken ¶
func (jwt *JWT) ParseToken(token string) (*JWTCustomClaims, error)
ParseToken 解析token
type JWTCustomClaims ¶
type JWTCustomClaims struct { UserID string `json:"user_id"` Username string `json:"user_name"` jwtgo.RegisteredClaims }
Click to show internal directories.
Click to hide internal directories.