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 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
httpswag command
examples
client command
server command
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
⌂ 换网址