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>
This commit is contained in:
Rajat Jindal
2024-07-10 01:56:29 +05:30
committed by GitHub
parent d9132d2a52
commit 001ceab784
2 changed files with 13 additions and 0 deletions
+4
View File
@@ -410,6 +410,10 @@ func urlErrorOp(method string) string {
// Any returned error will be of type *url.Error. The url.Error
// value's Timeout method will report true if the request timed out.
func (c *Client) Do(req *Request) (*Response, error) {
if c.Transport != nil {
return c.Transport.RoundTrip(req)
}
return c.do(req)
}
+9
View File
@@ -20,3 +20,12 @@ type readTrackingBody struct {
didRead bool
didClose bool
}
type Transport struct{}
var DefaultTransport RoundTripper = &Transport{}
// roundTrip implements a RoundTripper over HTTP.
func (t *Transport) RoundTrip(req *Request) (*Response, error) {
return roundTrip(req)
}