Skip to content

aereal/go-http-replay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Record and replay HTTP response for testing

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages