utils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

* @Author: lihuan * @Date: 2021-12-04 22:14:15 * @LastEditors: lihuan * @LastEditTime: 2021-12-05 13:42:41 * @Email: 17719495105@163.com

* @Author: lihuan * @Date: 2021-10-09 10:08:01 * @LastEditTime: 2021-10-13 10:56:46 * @Email: 17719495105@163.com

Index

Constants

View Source
const (
	Success          = 2000
	ParamsParseError = 2001
	RpcError         = 2002
	InvalidToken     = 2003
	TokenTimeout     = 2004
	TokenParse       = 2005
)

Variables

This section is empty.

Functions

func ErrorReponse

func ErrorReponse(ctx *gin.Context, r interface{})

func ErrorTranslate

func ErrorTranslate(e validator.ValidationErrors) string

func GenerateToken

func GenerateToken(id int, username, secret_password string, secret []byte, exp int) (string, error)

func GetMsg

func GetMsg(code int) string

func SuccessResponse

func SuccessResponse(ctx *gin.Context, data interface{})

func Validator

func Validator()

Types

type Application

type Application struct {
	Address string
	Port    int
	Mode    string
}

type Claims

type Claims struct {
	UserName string `json:"username"`
	ID       int    `json:"id"`
	Password string `json:"password"`
	jwt.StandardClaims
}

func ParseToken

func ParseToken(token string, secret []byte) (*Claims, error)

type Conf

type Conf struct {
	Application Application
	Token       Token
	Md5         Md5
}
var Cfg *Conf = nil

func GetConf

func GetConf(path string) (*Conf, error)

type Md5

type Md5 struct {
	Secret string
}

type Token

type Token struct {
	Secret     string
	ExpireTime int `yaml:"expire_time"`
}

Jump to

Keyboard shortcuts

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