feed through context
see https://github.com/ipfs/go-ipfs-api/pull/173 all credit to @optman This commit was moved from ipfs/go-ipfs-http-client@7b75a8c577988e4728474a02144bf5bf83260527
Steven Allen committed
Apr 4, 2019 at 00:36 UTC
70158edd5950671a26631788d15204350d174f52
2 files changed
+4
client/httpapi/request.go
+2
@@ -7,6 +7,7 @@ import (
7
)
8
9
type Request struct {
10
+ Ctx context.Context
11
ApiBase string
12
Command string
13
Args []string
@@ -25,6 +26,7 @@ func NewRequest(ctx context.Context, url, command string, args ...string) *Reque
26
"stream-channels": "true",
27
}
28
return &Request{
29
+ Ctx: ctx,
30
ApiBase: url + "/api/v0",
31
Command: command,
32
Args: args,
client/httpapi/response.go
+2
@@ -95,6 +95,8 @@ func (r *Request) Send(c *http.Client) (*Response, error) {
95
return nil, err
96
}
97
98
+ req = req.WithContext(r.Ctx)
99
+
100
// Add any headers that were supplied via the RequestBuilder.
101
for k, v := range r.Headers {
102
req.Header.Add(k, v)