Documentation ¶
Index ¶
- Variables
- func GetConfig() *config
- func GetGinConfig() (ginConfig *ginConfig)
- func GetServerConfig() (serverConfig *serverConfig)
- func GetSignKey() string
- func GetTokenConfig() (tokenConfig *tokenConfig)
- func GetWechatConfig() (wechatConfig *wechatConfig)
- 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 DB
- type Header
- type JWT
Constants ¶
This section is empty.
Variables ¶
View Source
var ( TokenExpired = errors.New("token 已经过期") TokenNotValidYet = errors.New("token 尚未激活") TokenMalformed = errors.New("token 格式错误") TokenInvalid = errors.New("token 无法解析") SignKey = "82060692FEFAC4511FC65110ADAB0F88a" )
定义一些常量
Functions ¶
func JWTAuth ¶
func JWTAuth() gin.HandlerFunc
func LoadDatasourceConfig ¶
func LoadServerConfig ¶
func LoadTokenConfig ¶
func SetSignKey ¶
Types ¶
type CustomClaims ¶
type CustomClaims struct { ID uint64 `json:"userId"` Name string `json:"name"` Phone string `json:"phone"` Openid string `json:"openid"` 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.