Skip to content

Commit

Permalink
transport/http: Add NopClient for stubbing http client response
Browse files Browse the repository at this point in the history
Adds a no-op HTTP client that will do nothing but return success.
Basically to prevent a middleware stack making a request with a
presigned URL flow.
  • Loading branch information
jasdel committed Oct 9, 2020
1 parent 642ec71 commit 21015eb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions transport/http/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,16 @@ func WrapLogClient(logger interface{ Logf(string, ...interface{}) }, client Clie
return resp, nil
})
}

// NopClient provides a client that ignores the request, and returns a empty
// successful HTTP response value.
type NopClient struct{}

// Do ignores the request and returns a 200 status empty response.
func (NopClient) Do(r *http.Request) (*http.Response, error) {
return &http.Response{
StatusCode: 200,
Header: http.Header{},
Body: http.NoBody,
}, nil
}

0 comments on commit 21015eb

Please sign in to comment.