utils

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StaticResources 静态资源路径, 相对 main.go 文件所在的
	StaticResources = "../internal/app/static/"
)

Variables

View Source
var (
	// Settings 系统配置
	Settings configs.ServerConfig
	// RouterGroup 路由规则
	RouterGroup map[string][]*Route
	// MysqlDataBase 全局变量
	MysqlDataBase *gorm.DB
	// RedisDataBase 全局变量
	RedisDataBase *redis.Client
)

全局变量

View Source
var (
	ErrTokenExpired     = errors.New("token is expired")
	ErrTokenNotValidYet = errors.New("token not active yet")
	ErrTokenMalformed   = errors.New("that's not even a token")
	ErrTokenInvalid     = errors.New("couldn't handle this token")
)

Functions

func AddRoute

func AddRoute(group string, route *Route)

func CreateToken

func CreateToken(id uint, nickName string, role uint) (string, error)

CreateToken 创建一个token

func GetNowFormatTodayTime

func GetNowFormatTodayTime() string

GetNowFormatTodayTime 获取今日时间

func StartGinServ

func StartGinServ(isDefault bool, middleware ...gin.HandlerFunc)

StartGinServ 启动 gin 服务

Types

type CustomClaims

type CustomClaims struct {
	ID          uint
	NickName    string
	AuthorityId uint
	jwt.StandardClaims
}

type JWT

type JWT struct {
	SigningKey []byte
}

func NewJWT

func NewJWT() *JWT

func (*JWT) ParseToken

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

type Route

type Route struct {
	// contains filtered or unexported fields
}

Route 路由定义结构体

func NewFileRouter

func NewFileRouter(url, method, filePath string) *Route

NewFileRouter 构造文件路由结构体

func NewRouter

func NewRouter(url, method string, handler *RouteHandle) *Route

NewRouter 构造路由结构体

func (*Route) ExecHandler

func (r *Route) ExecHandler() []gin.HandlerFunc

ExecHandler 执行模型中间件和 handlerFunc

func (*Route) GetFilePath

func (r *Route) GetFilePath() string

GetFilePath 获取 filePath 字段

func (*Route) GetMethod

func (r *Route) GetMethod() string

GetMethod 获取 method 字段

func (*Route) GetURL

func (r *Route) GetURL() string

GetURL 获取 uRL 字段

type RouteHandle

type RouteHandle struct {
	// contains filtered or unexported fields
}

RouteHandle 路由执行结构体

func NewRouteHandle

func NewRouteHandle(handlerFunc gin.HandlerFunc, moduleMiddlewares ...gin.HandlerFunc) *RouteHandle

Jump to

Keyboard shortcuts

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