Documentation ¶ Index ¶ Variables type CustomClaims type JWT func NewJWT(SigningKey string) *JWT func (j *JWT) CreateToken(claims CustomClaims) (string, error) func (j *JWT) ParseToken(tokenString string) (*CustomClaims, error) func (j *JWT) RefreshToken(tokenString string) (string, error) Constants ¶ This section is empty. Variables ¶ View Source var ( TokenExpired = errors.New("Token is expired") TokenNotValidYet = errors.New("Token not active yet") TokenMalformed = errors.New("That's not even a token") TokenInvalid = errors.New("Couldn't handle this token:") ) Functions ¶ This section is empty. Types ¶ type CustomClaims ¶ type CustomClaims struct { ID uint `json:"userid"` NickName string AuthorityId uint jwt.RegisteredClaims } type JWT ¶ type JWT struct { SigningKey []byte } func NewJWT ¶ func NewJWT(SigningKey string) *JWT func (*JWT) CreateToken ¶ func (j *JWT) CreateToken(claims CustomClaims) (string, error) 创建一个token func (*JWT) ParseToken ¶ func (j *JWT) ParseToken(tokenString string) (*CustomClaims, error) 解析 token func (*JWT) RefreshToken ¶ func (j *JWT) RefreshToken(tokenString string) (string, error) 更新token Source Files ¶ View all Source files jwt.go Click to show internal directories. Click to hide internal directories.