Skip to content

Commit

Permalink
updated to handle requests with context.
Browse files Browse the repository at this point in the history
convert ctx to Ctx (public)

convert ctx to Ctx (public)

fix the request setter, as it was not setting it to pass to cli.do(r)

added a comment for the Ctx variable
  • Loading branch information
jhonglocalsearchau authored and fiorix committed Nov 18, 2019
1 parent a93e82f commit 3f1d7d7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions soap/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package soap

import (
"bytes"
"context"
"encoding/xml"
"fmt"
"io"
Expand Down Expand Up @@ -56,6 +57,7 @@ type Client struct {
Config *http.Client // Optional HTTP client
Pre func(*http.Request) // Optional hook to modify outbound requests
Post func(*http.Response) // Optional hook to snoop inbound responses
Ctx context.Context // Optional variable to allow Context Tracking.
}

// XMLTyper is an abstract interface for types that can set an XML type.
Expand Down Expand Up @@ -132,6 +134,11 @@ func doRoundTrip(c *Client, setHeaders func(*http.Request), in, out Message) err
if c.Pre != nil {
c.Pre(r)
}

if c.Ctx != nil {
r = r.WithContext(c.Ctx)
}

resp, err := cli.Do(r)
if err != nil {
return err
Expand Down

0 comments on commit 3f1d7d7

Please sign in to comment.