Documentation ¶
Index ¶
- Variables
- func GetConfig() *config
- func GetDatasource() (datasource *datasource)
- func GetGinConfig() (ginconfig *ginConfig)
- func GetServerConfig() (serverconfig *serverConfig)
- func GetSignKey() string
- func GetTokenConfig() (tokenconfig *tokenConfig)
- func JWTAuth() gin.HandlerFunc
- func LoadConfig(path string) error
- func LoadDatasourceConfig(path string) error
- func LoadServerConfig(path string) error
- func LoadTokenConfig(path string) error
- func Logger(log *logrus.Logger) gin.HandlerFunc
- func SetSignKey(key string) string
- type CustomClaims
- type JWT
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 无法解析") SignKey string = "82040620FEFAC4511FC65000ADAB0F77" )
定义一些常量
Functions ¶
func JWTAuth ¶
func JWTAuth() gin.HandlerFunc
func LoadDatasourceConfig ¶
func LoadServerConfig ¶
func LoadTokenConfig ¶
func SetSignKey ¶
Types ¶
type CustomClaims ¶
type CustomClaims struct { ID string `json:"userId"` Name string `json:"name"` Phone string `json:"phone"` jwt.StandardClaims }
载荷,加一些系统需要的信息
type JWT ¶
type JWT struct {
SigningKey []byte
}
jwt签名结构
func (*JWT) CreateToken ¶
func (j *JWT) CreateToken(claims CustomClaims) (string, error)
生成 tokenConfig
func (*JWT) ResolveToken ¶
func (j *JWT) ResolveToken(tokenString string) (*CustomClaims, error)
解析 tokenConfig
Click to show internal directories.
Click to hide internal directories.