middleware

package
v0.0.0-...-2490bd5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

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,请重新登录")
)

定义错误

Functions

func Cors

func Cors() gin.HandlerFunc

func ErrorTrace

func ErrorTrace() gin.HandlerFunc

ErrorTrace 异常错误捕获

func JwtToken

func JwtToken() gin.HandlerFunc

JwtToken jwt中间件

func Log

func Log() gin.HandlerFunc

Types

type JWT

type JWT struct {
	JwtKey []byte
}

func NewJWT

func NewJWT() *JWT

func (*JWT) CreateToken

func (j *JWT) CreateToken(claims MyClaims) (string, error)

CreateToken 生成token

func (*JWT) ParserToken

func (j *JWT) ParserToken(tokenString string) (*MyClaims, error)

ParserToken 解析token

type MyClaims

type MyClaims struct {
	Username string `json:"username"`
	jwt.StandardClaims
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL