httplog

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: GPL-3.0 Imports: 5 Imported by: 0 modules, 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

Overview

Package httplog logs every HTTP request the proxy makes or serves.

Two wrappers cover the two directions: Transport logs outbound requests (to Anthropic, to the Codex backend, to the OAuth token endpoint — anything dialed through it), and Log wraps an http.Handler to log inbound requests (everything Claude Code sends the proxy). Both log the same fields — method, URL, request/response size, status, duration — so the two directions read the same way in the log.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Log

func Log(handler http.Handler) http.Handler

Log wraps handler to log every inbound request: the client's method, URL, request size, and — once the handler finishes — the response status, size and how long the request took.

Types

type Transport

type Transport struct {
	// Next is the transport to call. http.DefaultTransport is used when nil.
	Next http.RoundTripper
	// Label tags each log line, so requests from different clients (the
	// codex backend, the OAuth token endpoint, plain pass-through) can be
	// told apart at a glance.
	Label string
}

Transport wraps an http.RoundTripper to log every request it sends.

The response is logged when its body is closed, not when RoundTrip returns: a streaming response (Codex's Responses API never sends Content-Length) would otherwise be logged with an unknown size, or would have to be buffered in full just to count it. Logging on Close reports the real transferred size and the real duration — including how long a stream stayed open — at the cost of nothing appearing in the log for a response whose body a caller never closes. Every call site in this codebase closes its response bodies, so that cost is not paid in practice.

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements http.RoundTripper.

Jump to

Keyboard shortcuts

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