accesslog

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: Apache-2.0 Imports: 4 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 {
	Method   string `json:"method"`    // HTTP 方法
	Path     string `json:"path"`      // 请求路径
	Query    string `json:"query"`     // 查询参数
	IP       string `json:"ip"`        // 客户端 IP
	UserID   string `json:"user_id"`   // 用户 ID(如果已登录)
	ReqBody  string `json:"req_body"`  // 请求体
	RespBody string `json:"resp_body"` // 响应体
	Status   int    `json:"status"`    // HTTP 状态码
	Duration int64  `json:"duration"`  // 处理时间(毫秒)
	Error    string `json:"error"`     // 错误信息
}

AccessLog 访问日志结构

type Builder

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

Builder 访问日志中间件构建器

func NewBuilder

func NewBuilder(logFunc LogFunc) *Builder

NewBuilder 创建访问日志中间件构建器

func (*Builder) Build

func (b *Builder) Build() gin.HandlerFunc

Build 构建中间件

func (*Builder) WithMaxBodyLength

func (b *Builder) WithMaxBodyLength(length int) *Builder

WithMaxBodyLength 设置最大记录长度

func (*Builder) WithReqBody

func (b *Builder) WithReqBody(log bool) *Builder

WithReqBody 设置是否记录请求体

func (*Builder) WithRespBody

func (b *Builder) WithRespBody(log bool) *Builder

WithRespBody 设置是否记录响应体

type LogFunc

type LogFunc func(log *AccessLog)

LogFunc 日志处理函数类型

Jump to

Keyboard shortcuts

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