Skip to content

Instantly share code, notes, and snippets.

View mark-hartmann's full-sized avatar
🤔
"Working" from home?

Mark Hartmann mark-hartmann

🤔
"Working" from home?
View GitHub Profile
@mark-hartmann
mark-hartmann / string-roundtripper.go
Created February 12, 2022 08:50
a string based http.RoundTripper
// StringRoundTripper is a string based http.RoundTripper.
type StringRoundTripper struct {
bodyContent []byte
contentType string
}
func (t *StringRoundTripper) RoundTrip(_ *http.Request) (*http.Response, error) {
// The returned http.Response always has the status http.StatusOK, while the passed http.Request is not used. The
// actual implementation depends of course on the specific purpose.
res := &http.Response{