tools

package
v0.0.0-...-214d0a7 Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TokenIssuer = "StarkSim"
	SecretKey   = "42wqTE23123wffLU94342wgadgFs"

	AccessTokenExp  = time.Hour * 2
	RefreshTokenExp = time.Hour * 12

	JWTHeader  = "bearer "
	CookieName = "Authorization"
)

Variables

View Source
var ZeroTime = time.Time{}

Functions

func GenSnowflakeID

func GenSnowflakeID() int64

func GetDeployPath

func GetDeployPath(myPath string) string

GetDeployPath 获取启动项目的当前目录, 并和 myPath 拼接起来

func GetRootPath

func GetRootPath(myPath string) string

GetRootPath 搜索项目的文件根目录, 并和 myPath 拼接起来

func GetToken

func GetToken(CreateAt time.Time, UserID int64) (string, error)

GetToken 生成 JWT

func Init

func Init() error

func IsOneOf

func IsOneOf(obj string, list ...string) bool

func Shuffle

func Shuffle(list interface{}) []interface{}

Shuffle 切片随机排序,传入的参数类型为 []any

func StringToInt64

func StringToInt64(str string) int64

Types

type CustomClaims

type CustomClaims struct {
	UserID int64
	jwt.RegisteredClaims
}

func ParseToken

func ParseToken(tokenString string) (*CustomClaims, error)

ParseToken 解析token

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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