middleware

package
v0.0.0-...-011315e Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SECRET SECRET
	SECRET string = "asdhjsdhhdhdhdhsasd"
)

Variables

View Source
var Auth gin.HandlerFunc = func(c *gin.Context) {
	log.Printf("auth middleware")
	token, err := getToken(c)
	if err != nil || token == "" {
		handleErr(c, "")
		return
	}
	user, err := parseToken(token)
	if err != nil {
		handleErr(c, "解析token错误")
		return
	}
	c.Set("user", user)
}

Auth 用户认证中间件

Functions

func CreateToken

func CreateToken(u models.UserModel) (token string, err error)

CreateToken 创建token

func CreateTokenMaxAge

func CreateTokenMaxAge(u models.UserModel, maxAge int64) (tokens string, err error)

CreateTokenMaxAge 创建token

Types

This section is empty.

Jump to

Keyboard shortcuts

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