Skip to content
This repository was archived by the owner on Oct 5, 2023. It is now read-only.

Commit 7b75a8c

Browse files
committed
feed through context
see ipfs/go-ipfs-api#173 all credit to @optman
1 parent 7f25b2a commit 7b75a8c

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

request.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
)
88

99
type Request struct {
10+
Ctx context.Context
1011
ApiBase string
1112
Command string
1213
Args []string
@@ -25,6 +26,7 @@ func NewRequest(ctx context.Context, url, command string, args ...string) *Reque
2526
"stream-channels": "true",
2627
}
2728
return &Request{
29+
Ctx: ctx,
2830
ApiBase: url + "/api/v0",
2931
Command: command,
3032
Args: args,

response.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ func (r *Request) Send(c *http.Client) (*Response, error) {
9595
return nil, err
9696
}
9797

98+
req = req.WithContext(r.Ctx)
99+
98100
// Add any headers that were supplied via the RequestBuilder.
99101
for k, v := range r.Headers {
100102
req.Header.Add(k, v)

0 commit comments

Comments
 (0)