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

capture

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Overview

Package capture records sanitized HTTP traffic while proxying client requests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecisionsFromCapture

func DecisionsFromCapture(dir, client, out string) error

DecisionsFromCapture writes a redacted Plex decision corpus from a proxy capture.

func FixturesFromCapture

func FixturesFromCapture(dir, protocol, client, profileRoot, fixtureRoot string) error

FixturesFromCapture writes fixtures from observed reference responses without replay. Captures must contain origin markers; older ambiguous captures must be recaptured.

func ProfileFromCapture

func ProfileFromCapture(dir, protocol, client, out string) error

ProfileFromCapture converts an ordered capture into an explicitly captured profile. It refuses incomplete text requests, since they cannot be replayed faithfully.

Types

type Entry

type Entry struct {
	Sequence          int              `json:"sequence"`
	Protocol          string           `json:"protocol"`
	Client            string           `json:"client"`
	Request           Request          `json:"request"`
	Response          conform.Response `json:"response"`
	ResponseOrigin    string           `json:"response_origin,omitempty"`
	RequestTruncated  bool             `json:"request_truncated,omitempty"`
	ResponseTruncated bool             `json:"response_truncated,omitempty"`
}

Entry is a single ordered request and response. Bodies are always redacted; binary bodies are represented by bounded hashes, never bytes.

type Recorder

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

func New

func New(protocol, client, dir string, upstream *url.URL) (*Recorder, error)

New constructs a proxy without opening a listener.

func (*Recorder) Errors

func (r *Recorder) Errors() <-chan error

Errors reports a persistent capture failure so the listener can stop.

func (*Recorder) ServeHTTP

func (r *Recorder) ServeHTTP(w http.ResponseWriter, req *http.Request)

type Request

type Request struct {
	Method     string      `json:"method"`
	Path       string      `json:"path"`
	Headers    http.Header `json:"headers"`
	Body       []byte      `json:"body,omitempty"`
	BodyKind   string      `json:"body_kind,omitempty"`
	BodyLength int64       `json:"body_length,omitempty"`
	SHA256     string      `json:"sha256,omitempty"`
}

Jump to

Keyboard shortcuts

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