web

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeOctetStream = "application/octet-stream"
	TypeForm        = "application/x-www-form-urlencoded"
	TypeJson        = "application/json"
	TypeXml         = "application/xml"
	TypeJpg         = "image/jpeg"
	TypePng         = "image/png"
)

Variables

This section is empty.

Functions

func CheckSign

func CheckSign(sign, appid, path, ts string) (ok bool)

func File

func File(c *gin.Context, filePath, fileName string)

func JSON

func JSON(c *gin.Context, data interface{}, err error)

func Redirect

func Redirect(c *gin.Context, location string)

func VerifySign

func VerifySign(c *gin.Context)

VerifySign 验证Sign,签名规则,base64(md5(appid+path+ts)) todo: 当前支持60s验证,后续改成单次验证后即失效

Types

type CommonRsp

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

type Config

type Config struct {
	// http host
	Host string

	// http export port. :8080
	Port string

	// interface limit
	Limit *limit.Config

	// jaeger trace config
	Trace *trace.Config
}

type GinEngine

type GinEngine struct {
	Gin    *gin.Engine
	Tracer *trace.Tracer
	// contains filtered or unexported fields
}

func InitGin

func InitGin(c *Config) *GinEngine

func (*GinEngine) CORS

func (g *GinEngine) CORS() gin.HandlerFunc

CORS gin middleware cors

func (*GinEngine) Close added in v1.0.3

func (g *GinEngine) Close()

func (*GinEngine) Recovery

func (g *GinEngine) Recovery() gin.HandlerFunc

Recovery gin middleware recovery

func (*GinEngine) Release

func (g *GinEngine) Release() *GinEngine

func (*GinEngine) Start

func (g *GinEngine) Start()

type Pager

type Pager struct {
	PageNo   int `json:"page_no"`
	PageSize int `json:"page_size"`
}

func (Pager) Apply

func (p Pager) Apply(total int, data interface{}) interface{}

type RecoverInfo

type RecoverInfo struct {
	Time  string      `json:"time"`
	Url   string      `json:"url"`
	Err   string      `json:"error"`
	Query interface{} `json:"query"`
	Stack string      `json:"stack"`
}

Jump to

Keyboard shortcuts

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