Skip to content

Commit

Permalink
Doer: Inline the Doer type at least for now
Browse files Browse the repository at this point in the history
  • Loading branch information
earthboundkid committed Mar 30, 2023
1 parent fd08970 commit bd1c92b
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,14 @@ func (cl closeLogger) Close() error {
return cl.ReadCloser.Close()
}

// Doer is an interface with a Do method.
// DoerTransport converts a Doer into a Transport.
// It exists for compatibility with other libraries.
// A Doer is an interface with a Do method.
// Users should prefer Transport,
// because Do is the interface of http.Client
// which has higher level concerns.
type Doer interface {
func DoerTransport(cl interface {
Do(req *http.Request) (*http.Response, error)
}

// DoerTransport converts a Doer into a Transport.
func DoerTransport(cl Doer) Transport {
return RoundTripFunc(func(req *http.Request) (*http.Response, error) {
return cl.Do(req)
})
}) Transport {
return RoundTripFunc(cl.Do)
}

0 comments on commit bd1c92b

Please sign in to comment.