middleware

package
v0.0.51 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

* @Author: lisheng * @Date: 2022-10-19 16:21:40 * @LastEditTime: 2022-10-21 16:19:26 * @LastEditors: lisheng * @Description: * @FilePath: /gitee.com/liqiyuworks/jf-go-kit/middleware/jwt.go

* @Author: lisheng * @Date: 2022-10-11 00:12:42 * @LastEditTime: 2022-11-02 11:08:10 * @LastEditors: lisheng * @Description: 通用中间件 * @FilePath: /gitee.com/liqiyuworks/jf-go-kit/middleware/middleware.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cors

func Cors() gin.HandlerFunc

func GenerateToken

func GenerateToken(encryptedStr interface{}, expireTime time.Time) (string, error)

GenerateToken 一般在登录之后使用来生成 token 能够返回给前端

func JWTAuth

func JWTAuth() gin.HandlerFunc

JWTAuth 鉴权中间件

func LoggerToFile

func LoggerToFile() gin.HandlerFunc

日志记录到文件 在哪调用

func ParseToken

func ParseToken(tokenStr string) (*jwt.Token, error)

ParseToken 解析请求头中的 token string,转换成被解析后的 jwt.Token

Types

type AuthClaims

type AuthClaims struct {
	UserId interface{} `json:"userId"`
	jwt.StandardClaims
}

AuthClaims 是 claims struct

Jump to

Keyboard shortcuts

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