Documentation ¶
Index ¶
- Variables
- func SetConfigEnv(str string)
- func SetConfigFile(str string)
- type BaseClaims
- type CustomClaims
- type JWT
- type Util
- func (Util) GetClaims(token string, jwt structs.JWT) (*CustomClaims, error)
- func (Util) Logger() logger.Interface
- func (u Util) RegisterMany(ip string, port int32, password string, maxWorkerId int32, totalCount int32) []int32
- func (u Util) RegisterOne(ip string, port int32, password string, maxWorkerId int32) int32
- func (Util) UnRegister()
- func (Util) Validate(workerId int32) int32
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: ") )
View Source
var ( ConfigEnv = "APP_CONFIG" ConfigFile = "config.yaml" )
Functions ¶
func SetConfigEnv ¶
func SetConfigEnv(str string)
func SetConfigFile ¶
func SetConfigFile(str string)
Types ¶
type BaseClaims ¶
type CustomClaims ¶
type CustomClaims struct { BaseClaims BufferTime int64 jwt.StandardClaims }
Custom claims structure
type JWT ¶
type JWT struct { SigningKey []byte Control *singleflight.Group JWT structs.JWT }
func (*JWT) CreateClaims ¶
func (j *JWT) CreateClaims(baseClaims BaseClaims) CustomClaims
func (*JWT) CreateToken ¶
func (j *JWT) CreateToken(claims CustomClaims) (string, error)
CreateToken 创建一个token
func (*JWT) CreateTokenByOldToken ¶
func (j *JWT) CreateTokenByOldToken(oldToken string, claims CustomClaims) (string, error)
CreateTokenByOldToken 旧token 换新token 使用归并回源避免并发问题
func (*JWT) ParseToken ¶
func (j *JWT) ParseToken(tokenString string) (*CustomClaims, error)
ParseToken 解析 token
type Util ¶
type Util struct { }
func (Util) RegisterMany ¶
func (Util) RegisterOne ¶
func (Util) UnRegister ¶
func (Util) UnRegister()
Click to show internal directories.
Click to hide internal directories.