httputil

package module
v0.0.0-...-8585d0b Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2022 License: LGPL-2.1 Imports: 20 Imported by: 4

Documentation

Index

Constants

View Source
const (
	Nil reqType = iota
	JSON
	XML
	Form
	Query
	FormPost
	FormMultipart
	ProtoBuf
	MsgPack
	YAML
	Uri
	Header
	TOML
)

Variables

View Source
var (
	ErrNotFound = errors.New("no this record")
	ErrInsert   = errors.New("insert fail")
	ErrUpdate   = errors.New("update fail")
	ErrDelete   = errors.New("delete fail")
)

各类错误类型

View Source
var DefaultQPS = 100

Functions

func BaseStart

func BaseStart(ctx context.Context, engine *gin.Engine, port string, logger *logger.ZapX)

func GoMicroServer

func GoMicroServer(ctx context.Context, engine *gin.Engine, servername, port string, logger *logger.ZapX) error

uber: 漏桶限流实现 limiter: 令牌桶限流实现 hystrix: 熔断器实现

func RegisterGroup

func RegisterGroup(engine *gin.Engine, group *RouterGroup)

func RegisterGroupSimple

func RegisterGroupSimple(engine *gin.Engine, Relative string, Middlewares []gin.HandlerFunc, Handlers []RouterHandler)

func RegisterHandler

func RegisterHandler(engine *gin.Engine, handlers ...RouterHandler)

func Start

func Start(engine *gin.Engine, port string, logger *logger.ZapX)

With Singal Handle

Types

type Handler

type Handler struct{}

func (*Handler) DoReq

func (b *Handler) DoReq(ctx *gin.Context, typ_ reqType, req interface{}) error

序列化请求以及进行校验

func (*Handler) DoRes

func (b *Handler) DoRes(ctx *gin.Context, code ResponseCode, ext map[string]interface{})

type ResponseCode

type ResponseCode uint32
const (
	ServerOK ResponseCode = iota
	ServerError
)

运行状态

const (
	// 参数问题
	ParamEmpty ResponseCode = 101 + iota
	ParamInvalid
)

func (ResponseCode) String

func (c ResponseCode) String() string

type RouterGroup

type RouterGroup struct {
	Relative    string
	Middlewares []gin.HandlerFunc
	Handler     []RouterHandler
}

type RouterHandler

type RouterHandler struct {
	Method     string
	Url        string
	Handler    gin.HandlerFunc
	Middleware []gin.HandlerFunc
}

func H

func H(method string, url string, handler gin.HandlerFunc, middleware []gin.HandlerFunc) RouterHandler

Directories

Path Synopsis
cmd
examples
middleware
jwt
plugins
captcha Module
todolist Module
store
mysql Module
redis Module
sqlite Module

Jump to

Keyboard shortcuts

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