Last active
March 14, 2017 23:09
-
-
Save bjjb/62da65c317d3a3af7e5b64689b219b12 to your computer and use it in GitHub Desktop.
An incrementing http client RoundTripper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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