middleware

package
v0.0.0-...-34b391d Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthJwt

func AuthJwt() gin.HandlerFunc

AuthJwt 验证授权中间件 https://gin-gonic.com/docs/examples/custom-middleware/ https://gin-gonic.com/docs/examples/cookie/ https://github.com/dgrijalva/jwt-go 登录成功 设置Jwt jwtToken, _ := middleware.GenerateJwt(account.Username, common.DecodeBase64(account.Password)) middleware.SetJwt(c, "jwtToken", jwtToken) 注销成功 删除Jwt middleware.DeleteJwt(c, "jwtToken")

func AuthName

func AuthName() gin.HandlerFunc

AuthName 验证姓名中间件 https://gin-gonic.com/docs/examples/custom-middleware/

func AuthRule

func AuthRule() gin.HandlerFunc

AuthRule 验证规则中间件 https://gin-gonic.com/docs/examples/custom-middleware/

func DeleteJwt

func DeleteJwt(c *gin.Context, tokenKey interface{})

DeleteJwt 删除Jwt

func GenerateJwt

func GenerateJwt(username string, password string) (string, error)

GenerateJwt 生成Jwt https://godoc.org/github.com/dgrijalva/jwt-go#NewWithClaims

func GetJwt

func GetJwt(c *gin.Context, tokenKey interface{}) (tokenValue interface{})

GetJwt 获取Jwt

func SetJwt

func SetJwt(c *gin.Context, tokenKey interface{}, tokenValue interface{})

SetJwt 设置Jwt

func StatCost

func StatCost() gin.HandlerFunc

StatCost 请求耗时中间件 https://gin-gonic.com/docs/examples/custom-middleware/

Types

type JwtClaims

type JwtClaims struct {
	Username           string `json:"username"`
	Password           string `json:"password"`
	jwt.StandardClaims        // jwt包中的默认字段
}

JwtClaims 结构体

func ParseJwt

func ParseJwt(tokenString string) (*JwtClaims, error)

ParseJwt 解析Jwt https://godoc.org/github.com/dgrijalva/jwt-go#ParseWithClaims

Jump to

Keyboard shortcuts

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