common

package
v3.0.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2022 License: AGPL-3.0 Imports: 18 Imported by: 12

Documentation

Index

Constants

View Source
const MaxInt = int(MaxUint >> 1)
View Source
const MaxUint = ^uint(0)
View Source
const MinInt = -MaxInt - 1
View Source
const MinUint = 0

Variables

View Source
var HttpClient = &http.Client{}
View Source
var SecretKey []byte

Functions

func ErrorResp

func ErrorResp(c *gin.Context, err error, code int, l ...bool)

ErrorResp is used to return error response @param l: if true, log error

func ErrorStrResp

func ErrorStrResp(c *gin.Context, str string, code int, l ...bool)

func GenerateToken

func GenerateToken(username string) (tokenString string, err error)

func GetApiUrl

func GetApiUrl(r *http.Request) string

func Proxy

func Proxy(w http.ResponseWriter, r *http.Request, link *model.Link, file model.Obj) error

func Sign

func Sign(obj model.Obj, encrypt bool) string

func SuccessResp

func SuccessResp(c *gin.Context, data ...interface{})

Types

type PageReq

type PageReq struct {
	Page    int `json:"page" form:"page"`
	PerPage int `json:"per_page" form:"per_page"`
}

func (*PageReq) Validate

func (p *PageReq) Validate()

type PageResp

type PageResp struct {
	Content interface{} `json:"content"`
	Total   int64       `json:"total"`
}

type Resp

type Resp struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

type UserClaims

type UserClaims struct {
	Username string `json:"username"`
	jwt.RegisteredClaims
}

func ParseToken

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

Jump to

Keyboard shortcuts

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