A zero-dependency library for transparently recording HTTP conversations between Go HTTP clients and servers. Works with most Go libraries that support passing in http.Client or http.RoundTripper.
Recordings can be exported as HTTP Archives (HAR) which can be viewed in most browsers.
- Record requests and responses from Go applications and libraries using the standard Go HTTP client.
- Export to Browser compatible HAR files.
- Low-level timing information is included; you can see how long each component of your request is taking.
- Tracking the IP address of the server being connected to (serverIPAddress).
- Page Tracking (see: examples/multipaged/multipaged.go).
- Header Redaction (see examples/redact/redact.go).
You might find this library useful for the following tasks
- Debugging HTTP client Applications; use for when you need to be able to visualize and inspect applications you're writing that are interacting with HTTP servers.
- Understanding how third party libraries are making requests.
- Allowing your application to collect diagnostic information which your users can send you to help with bug reporting.
go get github.com/swedishborgie/daytripper
See examples/streaming/streaming.go for the full example.
client := http.DefaultClient
// Open the file to write the HAR to.
fp, _ := os.Create("log.har")
defer fp.Close()
// Create the recorder and pass it the client. It will wrap the http.Transport.
dt, _ := daytripper.New(
daytripper.WithReceiver(streaming.New(fp)),
daytripper.WithClient(client),
)
// Close the recorder before exiting — this finalizes the HAR JSON and flushes it to fp.
defer dt.Close()
// Make the request as normal.
req, _ := http.NewRequestWithContext(context.Background(), "GET", "https://example.com/", nil)
rsp, _ := client.Do(req)
defer rsp.Body.Close()
body, _ := io.ReadAll(rsp.Body)You can then open the resulting log.har file in most browsers (e.g. Chrome / Firefox) by dragging and dropping the
file into the Network Inspector window:

