Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,15 @@ func createHTTPRequest(c *Client, r *Request) (err error) {
r.RawRequest.URL.Host = r.URL
}

// Use context if it was specified
if r.ctx != nil {
r.RawRequest = r.RawRequest.WithContext(r.ctx)
}

// Enable trace
if c.trace || r.trace {
r.clientTrace = &clientTrace{}
r.RawRequest = r.RawRequest.WithContext(r.clientTrace.createContext())
r.ctx = r.clientTrace.createContext(r.Context())
}

// Use context if it was specified
if r.ctx != nil {
r.RawRequest = r.RawRequest.WithContext(r.ctx)
}

// assign get body func for the underlying raw request instance
Expand Down
4 changes: 2 additions & 2 deletions trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ type clientTrace struct {
// Trace unexported methods
//_______________________________________________________________________

func (t *clientTrace) createContext() context.Context {
func (t *clientTrace) createContext(ctx context.Context) context.Context {
return httptrace.WithClientTrace(
context.Background(),
ctx,
&httptrace.ClientTrace{
GetConn: func(_ string) {
t.getConn = time.Now()
Expand Down