Skip to content

Latest commit

 

History

History
59 lines (43 loc) · 1.48 KB

README.md

File metadata and controls

59 lines (43 loc) · 1.48 KB

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