utils

package
v0.0.0-...-6f596e7 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2024 License: Apache-2.0 Imports: 23 Imported by: 3

Documentation

Index

Constants

View Source
const (
	SIGNING_KEY = "EHNo3Cwyph*XbYlFJS^WL@&0#r#D1B%W"
)

Variables

This section is empty.

Functions

func GenerateMessageCode

func GenerateMessageCode(width int) string

func GetFreePort

func GetFreePort() (int, error)

获取一个空闲端口,范围在49152-65535 熟知端口号:0-1023;已登记端口号:1024-49151;临时端口号:49152-65535

func GetUUID

func GetUUID() string

获取 UUID

func GracefulExit

func GracefulExit()

优雅退出

func HandleGrpcError

func HandleGrpcError(c *gin.Context, err error)

HandleGrpcError 处理grpc的error

func HandleValidatorError

func HandleValidatorError(c *gin.Context, err error)

HandleValidatorError 处理验证器的error

func Marshal

func Marshal(data any) []byte

序列化(忽略错误)

func NewRestyClient

func NewRestyClient(ctx context.Context, reqHeaders map[string]string, reqBody []byte) *resty.Request

Types

type JWT

type JWT struct {
	SigningKey []byte
}
var (
	Jwt *JWT
)

func NewJWT

func NewJWT() *JWT

func (JWT) CreateToken

func (j JWT) CreateToken(claims *jwt.MapClaims) (string, error)

func (JWT) ParseToken

func (j JWT) ParseToken(tokenString string) (*jwt.Token, error)

Jump to

Keyboard shortcuts

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