Skip to content

Instantly share code, notes, and snippets.

@bjjb
Last active March 14, 2017 23:09
Show Gist options
  • Select an option

  • Save bjjb/62da65c317d3a3af7e5b64689b219b12 to your computer and use it in GitHub Desktop.

Select an option

Save bjjb/62da65c317d3a3af7e5b64689b219b12 to your computer and use it in GitHub Desktop.
An incrementing http client RoundTripper
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
"testing"
)
type incrt byte
func (rt incrt) RoundTrip(req *http.Request) (*http.Response, error) {
rt++
return &http.Response{
StatusCode: int(rt + 200),
Status: fmt.Sprintf("%d Foo", rt+200),
Header: http.Header{"X-Value": []string{fmt.Sprintf("test/foo%d", rt)}},
Body: ioutil.NopCloser(bytes.NewReader([]byte{byte(rt) + '0'})),
}, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment