Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrMissingHeader means the `Authorization` header was empty. ErrMissingHeader = errors.New("the length of the `Authorization` header is zero") )
Functions ¶
func Sign ¶
func Sign(ctx context.Context, payload map[string]interface{}, secret string, timeout int64) (tokenString string, err error)
Sign signs the payload with the specified secret. The token content. iss: (Issuer)签发者 iat: (Issued At)签发时间,用Unix时间戳表示 exp: (Expiration Time)过期时间,用Unix时间戳表示 aud: (Audience)接收该JWT的一方 sub: (Subject)该JWT的主题 nbf: (Not Before)不要早于这个时间 jti: (JWT ID)用于标识JWT的唯一ID
Types ¶
type Payload ¶
type Payload struct {
UserID uint64
}
Payload is the data of the JSON web token.
type Response ¶
type Response struct { Code int `json:"code"` Message string `json:"message"` Data interface{} `json:"data"` }
func NewResponse ¶
func NewResponse() *Response
type ValidError ¶
func (*ValidError) Error ¶
func (v *ValidError) Error() string
type ValidErrors ¶
type ValidErrors []*ValidError
func BindAndValid ¶
func BindAndValid(c *gin.Context, v interface{}) (bool, ValidErrors)
func (ValidErrors) Error ¶
func (v ValidErrors) Error() string
func (ValidErrors) Errors ¶
func (v ValidErrors) Errors() []string
Click to show internal directories.
Click to hide internal directories.