middleware

package
v2.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessLog

type AccessLog struct {
	LogId      string      `json:"id"`        // 请求id
	Path       string      `json:"path"`      //  请求路径
	Method     string      `json:"method"`    //  请求方法
	Query      string      `json:"query"`     // 请求参数
	Proto      string      `json:"proto"`     // 请求协议
	Headers    http.Header `json:"headers"`   // 请求头
	ReqBody    string      `json:"req_body"`  //  请求体
	ClientIP   string      `json:"client_ip"` // 客户端IP
	Status     int         `json:"status"`
	RespBody   string      `json:"resp_body"`   //  响应体
	RespHeader http.Header `json:"resp_header"` // 响应头
	StartTime  int64       `json:"start_time"`
	StopTime   int64       `json:"stop_time"`
	Duration   int64       `json:"duration"` // 请求耗时
}

func (*AccessLog) ReqLogPrint

func (a *AccessLog) ReqLogPrint(log logx.Loggerx)

ReqLogPrint 请求日志打印

func (*AccessLog) RespLogPrint

func (a *AccessLog) RespLogPrint(log logx.Loggerx)

RespLogPrint 响应日志打印

type GinLogx

type GinLogx struct {
	// contains filtered or unexported fields
}

func NewGinLogx

func NewGinLogx(logx logx.Loggerx) *GinLogx

NewGinLogx 自定义Gin日志中间件【基于zeroLog高性能日志库】

func (*GinLogx) AllowReqBody

func (l *GinLogx) AllowReqBody(isPrint bool) *GinLogx

AllowReqBody 允许打印请求体

func (*GinLogx) AllowRespBody

func (l *GinLogx) AllowRespBody(isPrint bool) *GinLogx

AllowRespBody 允许打印响应体

func (*GinLogx) BuildGinHandlerLog

func (g *GinLogx) BuildGinHandlerLog() gin.HandlerFunc

ZerologLogger 自定义Gin日志中间件

  • 【注意,中间件需在gin的Handler注册中间件最前,否则可能会获取不到请求内容】

func (*GinLogx) SetMaxBodySize

func (l *GinLogx) SetMaxBodySize(size int64) *GinLogx

SetMaxBodySize 设置请求体和响应体最大读取大小(字节)

Jump to

Keyboard shortcuts

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