Help us shape the future of Go! Take the 2026 Go Developer Survey

bodydump

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultMaxRequestBytes and DefaultMaxResponseBytes bound
	// captured payloads while preserving total byte counts.
	DefaultMaxRequestBytes  int64 = 1 << 20
	DefaultMaxResponseBytes int64 = 1 << 20
)

Variables

This section is empty.

Functions

func New

func New(configs ...Config) zinc.Middleware

New captures request and response bodies for Config.Observe without changing the bytes downstream handlers read or write. The request body is copied as handlers read it, up to MaxRequestBytes, so a body nothing reads isn't captured and capture never reads more than the handler does. An error a handler returns is rendered while capture is active, so the snapshot holds the response the client got. Configure Redact before exporting snapshots.

Types

type Config

type Config struct {
	Observe          Observer
	Redact           Redactor
	MaxRequestBytes  int64
	MaxResponseBytes int64
}

Config controls capture limits, redaction, and observation.

type Observer

type Observer func(*zinc.Context, Snapshot)

Observer receives one completed request snapshot.

type Redactor

type Redactor func(*zinc.Context, *Snapshot)

Redactor removes sensitive data before observation.

type Snapshot

type Snapshot struct {
	Method            string
	Path              string
	RoutePath         string
	Status            int
	RequestBody       []byte
	ResponseBody      []byte
	RequestBytes      int64
	ResponseBytes     int64
	RequestTruncated  bool
	ResponseTruncated bool
	Error             error
}

Snapshot contains bounded request and response captures.

Jump to

Keyboard shortcuts

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