Documentation
¶
Index ¶
- Variables
- func AsyncMap[T1 any, T2 any](arr *[]T1, f func(T1) T2) *[]T2
- func BcryptCheck(password, hash string) bool
- func BcryptHash(password string) string
- func CheckError(err error)
- func DateOfString(date string) (time.Time, error)
- func Filter[T any](arr []T, fun func(T) bool) []T
- func HttpGet[T any, R any](uri string, headers map[string]string, params T, resp R) error
- func HttpPost[T any, R any](uri string, headers map[string]string, body T, resp R) error
- func JSONToMap(content interface{}) []map[string]any
- func JsonTimeFormat(t JsonTime) string
- func Map[T1 any, T2 any](arr *[]T1, f func(T1) T2) *[]T2
- func PathExists(path string) (bool, error)
- func StringToTime(t string) (time.Time, error)
- func TimeFormat(t time.Time) string
- func TimeOfString(t string) (time.Time, error)
- func Translator(locale string) (err error)
- func Validate(val interface{})
- type BaseClaims
- type Cache
- type CustomClaims
- type JWT
- type JsonTime
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 Trans ut.Translator
Functions ¶
func CheckError ¶
func CheckError(err error)
func JsonTimeFormat ¶
func PathExists ¶
func TimeFormat ¶
func Translator ¶
Types ¶
type BaseClaims ¶
type CustomClaims ¶
type CustomClaims struct {
BaseClaims
BufferTime int64
jwt.RegisteredClaims
}
type JWT ¶
type JWT struct {
SigningKey []byte
}
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 JsonTime ¶
JsonTime format json time field by myself
func (JsonTime) MarshalJSON ¶
MarshalJSON on JsonTime format Time field with Y-m-d H:i:s
func (*JsonTime) UnmarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.