zhttp

package
v0.0.0-...-e38cb6b Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2022 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Access

func Access(ng engine.Engine) gin.HandlerFunc

func AddWrapHandlerCtxFn

func AddWrapHandlerCtxFn(c *gin.Context, fns ...wrapHandlerCtxFn)

AddWrapHandlerCtxFn 增加handlerctx包装器

func DisablePBValidate

func DisablePBValidate(b bool) func(c *gin.Context)

DisablePBValidate 对实现validate接口的pb.message禁用pb数据校验

func ExtractLogger

func ExtractLogger(c *gin.Context) *logrus.Entry

func ExtractTracerID

func ExtractTracerID(c *gin.Context) string

func ExtractbroccoliCtx

func ExtractbroccoliCtx(c *gin.Context) context.Context

func GenerateGinHandle

func GenerateGinHandle(handleFunc interface{}) func(c *gin.Context)

func GinRecovery

func GinRecovery() gin.HandlerFunc

GinRecovery 使用gin框架默认的Recovery

func GinRecoveryWithWriter

func GinRecoveryWithWriter(out io.Writer) gin.HandlerFunc

GinRecoveryWithWriter 使用gin框架默认的RecoveryWithWriter

func Method

func Method(groups map[string]*gin.RouterGroup, r *Route)

func NotFound

func NotFound(ng engine.Engine) gin.HandlerFunc

func Recovery

func Recovery() gin.HandlerFunc

Recovery 框架内部的recovery

func SetDefaultValidator

func SetDefaultValidator(v binding.StructValidator)

SetCustomValidator 设置gin默认的数据校验器

v为nil则使用框架定义的校验器

func SetReWriteErrFn

func SetReWriteErrFn(f reWriteErrFn) func(c *gin.Context)

SetReWriteErrFn 自定义错误处理

func SetReWriteResponseFn

func SetReWriteResponseFn(f reWriteResponseFn) func(c *gin.Context)

SetReWriteResponseFn 自定义返回处理

func TagRawRsp

func TagRawRsp(raw bool) func(c *gin.Context)

TagRawRsp 标记返回值原样返回

func UseGinBindValidateForPB

func UseGinBindValidateForPB(b bool) func(c *gin.Context)

UseGinBindValidateForPB 使用gin bind对pb进行数据绑定和校验

func WrapHandlerCtx

func WrapHandlerCtx(fns ...wrapHandlerCtxFn) func(c *gin.Context)

WrapHandlerCtx 包装handler ctx,支持多个包装器(通过gin中间件添加)

Types

type CustomRouteFn

type CustomRouteFn func(routes map[RouteLink]*Route)

type ErrorResponseHandler

type ErrorResponseHandler func(c *gin.Context, err error)
var ErrorResponse ErrorResponseHandler = defaultErrorResponse

type Route

type Route struct {
	RLink       RouteLink
	Method      string
	Path        string
	Group       string
	Middlewares gin.HandlersChain
	Handle      gin.HandlerFunc
}

func (*Route) AddMW

func (r *Route) AddMW(h ...gin.HandlerFunc)

func (*Route) Mix

func (r *Route) Mix() gin.HandlersChain
type RouteLink string

func (RouteLink) AddMW

func (rl RouteLink) AddMW(routes map[RouteLink]*Route, h ...gin.HandlerFunc)

func (RouteLink) SetGroup

func (rl RouteLink) SetGroup(routes map[RouteLink]*Route, group string)

type SuccessResponseHandler

type SuccessResponseHandler func(c *gin.Context, rsp interface{})
var SuccessResponse SuccessResponseHandler = defaultSuccessResponse

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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