httplog

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package httplog logs HTTP traffic for --debug, with the secrets taken out.

It is a leaf package on purpose. Both the traffic to Google (whose request URL carries the Firebase API key and whose request body carries the password) and the traffic to fulfillmenttools (whose every request carries a bearer token) have to be logged by the same rules, and the two packages that own those clients — auth and client — must not import each other. The redaction lives here so that there is exactly one implementation of it.

What is removed

The Authorization header, the ?key= query parameter, and any password, token or refresh token appearing as a JSON field or a form field. A --debug dump is the single most likely thing a user pastes into a bug report, so the bar is not "unlikely to leak" but "cannot".

Index

Constants

View Source
const Redacted = "[REDACTED]"

Redacted is what a secret is replaced with. It is deliberately conspicuous: a reader who sees it knows something was removed, rather than wondering whether the value really was empty.

Variables

This section is empty.

Functions

func Redact

func Redact(s string, extra ...string) string

Redact removes from s the API key, any password or token it carries, and any of the extra secrets given that appear in it verbatim.

Very short extras are left alone: replacing every occurrence of a three-letter password would mangle the message into uselessness, and the message is the only thing the user has to go on.

Types

type Transport

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

Transport logs every request it carries, and the response to it, to w.

It is a RoundTripper rather than a wrapper around the call sites because that is the only layer that sees what was *actually* sent: the headers another RoundTripper added, the body the generated client encoded. It changes nothing about the request.

func New

func New(w io.Writer, base http.RoundTripper) *Transport

New returns a Transport logging to w. A nil base means http.DefaultTransport.

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