web

package
v1.0.16 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2021 License: Apache-2.0 Imports: 19 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 ReadRequestBody added in v1.0.16

func ReadRequestBody(req *http.Request) (bs []byte, 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 {
	Addr         string         `json:"addr" yaml:"addr" toml:"addr"`                            // addr :8080
	ReadTimeout  xtime.Duration `json:"read_timeout" yaml:"read_timeout" toml:"read_timeout"`    // read_timeout
	WriteTimeout xtime.Duration `json:"write_timeout" yaml:"write_timeout" toml:"write_timeout"` // write_timeout
	Debug        bool           `json:"debug" yaml:"debug" toml:"debug"`                         // is show log
	Limiter      *limit.Config  `json:"limiter" yaml:"limiter" toml:"limiter"`                   // interface limit
	Trace        *trace.Config  `json:"trace" yaml:"trace" toml:"trace"`                         // jaeger 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) 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"`
	RequestURI  string      `json:"request_uri"`
	Body        string      `json:"body"`
	RequestInfo string      `json:"request_info"`
	Err         interface{} `json:"error"`
	Stack       string      `json:"stack"`
}

Jump to

Keyboard shortcuts

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