Record and replay HTTP response for testing
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.travis.yml
LICENSE
README.md
mw.go
transport.go
transport_test.go

README.md

Build Status MIT License GoDoc

go-http-replay

Record and replay HTTP response for testing

Synopsis

Replay HTTP response or fetch from the remote:

import (
	"net/http"
	"testing"

	httpreplay "github.com/aereal/go-http-replay"
)

func Test_http_lib(t *testing.T) {
	httpClient := &http.Client{
		Transport: httpreplay.NewReplayOrFetchTransport("./testdata", http.DefaultClient),
	}
	// httpClient will behave like the client that created from NewReplayTransport but DO actual request if local cache is missing.
}

Only replay HTTP response from cache:

import (
	"net/http"
	"testing"

	httpreplay "github.com/aereal/go-http-replay"
)

func Test_http_lib(t *testing.T) {
	httpClient := &http.Client{
		Transport: httpreplay.NewReplayTransport("./testdata"),
	}
	// httpClient will not do actual request to remote sites but returns the response from local cache files.
}

See also

Author

  • aereal