apidump

package
v2.37.3 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: AGPL-3.0 Imports: 17 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// SuffixRequest is the file suffix for request dump files.
	SuffixRequest = ".req.txt"
	// SuffixResponse is the file suffix for response dump files.
	SuffixResponse = ".resp.txt"
	// SuffixError is the file suffix for error dump files written when a request fails.
	SuffixError = ".req_error.txt"
)

Variables

This section is empty.

Functions

func NewPassthroughMiddleware

func NewPassthroughMiddleware(transport http.RoundTripper, baseDir string, provider string, logger slog.Logger, clk quartz.Clock) http.RoundTripper

NewPassthroughMiddleware returns http.RoundTripper that dumps requests and responses to files. If baseDir is empty, returns the original transport unchanged. Used for logging in pass through routes.

Types

type Dumper added in v2.34.0

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

Dumper writes HTTP request/response dump files to disk. Each Dumper is associated with a single base path; the .req.txt, .resp.txt, and .req_error.txt suffixes are appended automatically.

func NewDumper added in v2.34.0

func NewDumper(dumpPath string, logger slog.Logger) *Dumper

NewDumper returns a Dumper that writes dump files rooted at dumpPath. The caller constructs a unique path per request (e.g. provider + request ID). logger is used for non-fatal I/O warnings.

func (*Dumper) DumpError added in v2.34.0

func (d *Dumper) DumpError(reqErr error) error

DumpError writes the error message to a .req_error.txt file.

func (*Dumper) DumpRequest added in v2.34.0

func (d *Dumper) DumpRequest(req *http.Request) error

DumpRequest writes the request to a .req.txt file. The request body is read and restored so downstream consumers are unaffected.

func (*Dumper) DumpResponse added in v2.34.0

func (d *Dumper) DumpResponse(resp *http.Response) error

DumpResponse writes the response headers and wraps the body so it streams to a .resp.txt file as it is consumed.

type Middleware

type Middleware = func(*http.Request, MiddlewareNext) (*http.Response, error)

Middleware is an HTTP middleware function compatible with SDK WithMiddleware options.

func NewBridgeMiddleware

func NewBridgeMiddleware(baseDir string, provider string, model string, interceptionID uuid.UUID, logger slog.Logger, clk quartz.Clock) Middleware

NewBridgeMiddleware returns a middleware function that dumps requests and responses to files. If baseDir is empty, returns nil (no middleware).

type MiddlewareNext

type MiddlewareNext = func(*http.Request) (*http.Response, error)

MiddlewareNext is the function to call the next middleware or the actual request.

Jump to

Keyboard shortcuts

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