Skip to content

Commit 001ceab

Browse files
authored
add bare minimum DefaultTransport (#32)
* add bare minimum DefaultTransport Signed-off-by: Rajat Jindal <rajatjindal83@gmail.com> * use transport if explicitly configured by client Signed-off-by: Rajat Jindal <rajatjindal83@gmail.com> --------- Signed-off-by: Rajat Jindal <rajatjindal83@gmail.com>
1 parent d9132d2 commit 001ceab

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

http/client.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,10 @@ func urlErrorOp(method string) string {
410410
// Any returned error will be of type *url.Error. The url.Error
411411
// value's Timeout method will report true if the request timed out.
412412
func (c *Client) Do(req *Request) (*Response, error) {
413+
if c.Transport != nil {
414+
return c.Transport.RoundTrip(req)
415+
}
416+
413417
return c.do(req)
414418
}
415419

http/transport.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,12 @@ type readTrackingBody struct {
2020
didRead bool
2121
didClose bool
2222
}
23+
24+
type Transport struct{}
25+
26+
var DefaultTransport RoundTripper = &Transport{}
27+
28+
// roundTrip implements a RoundTripper over HTTP.
29+
func (t *Transport) RoundTrip(req *Request) (*Response, error) {
30+
return roundTrip(req)
31+
}

0 commit comments

Comments
 (0)