Skip to content

Commit 3f1d7d7

Browse files
jhonglocalsearchaufiorix
authored andcommitted
updated to handle requests with context.
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
1 parent a93e82f commit 3f1d7d7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Diff for: soap/client.go

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package soap
33

44
import (
55
"bytes"
6+
"context"
67
"encoding/xml"
78
"fmt"
89
"io"
@@ -56,6 +57,7 @@ type Client struct {
5657
Config *http.Client // Optional HTTP client
5758
Pre func(*http.Request) // Optional hook to modify outbound requests
5859
Post func(*http.Response) // Optional hook to snoop inbound responses
60+
Ctx context.Context // Optional variable to allow Context Tracking.
5961
}
6062

6163
// XMLTyper is an abstract interface for types that can set an XML type.
@@ -132,6 +134,11 @@ func doRoundTrip(c *Client, setHeaders func(*http.Request), in, out Message) err
132134
if c.Pre != nil {
133135
c.Pre(r)
134136
}
137+
138+
if c.Ctx != nil {
139+
r = r.WithContext(c.Ctx)
140+
}
141+
135142
resp, err := cli.Do(r)
136143
if err != nil {
137144
return err

0 commit comments

Comments
 (0)