Skip to content

Commit

Permalink
feed through context
Browse files Browse the repository at this point in the history
see ipfs/go-ipfs-api#173

all credit to @optman


This commit was moved from ipfs/go-ipfs-http-client@7b75a8c
  • Loading branch information
Stebalien committed Apr 4, 2019
1 parent b22be85 commit 70158ed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions client/httpapi/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
)

type Request struct {
Ctx context.Context
ApiBase string
Command string
Args []string
Expand All @@ -25,6 +26,7 @@ func NewRequest(ctx context.Context, url, command string, args ...string) *Reque
"stream-channels": "true",
}
return &Request{
Ctx: ctx,
ApiBase: url + "/api/v0",
Command: command,
Args: args,
Expand Down
2 changes: 2 additions & 0 deletions client/httpapi/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ func (r *Request) Send(c *http.Client) (*Response, error) {
return nil, err
}

req = req.WithContext(r.Ctx)

// Add any headers that were supplied via the RequestBuilder.
for k, v := range r.Headers {
req.Header.Add(k, v)
Expand Down

0 comments on commit 70158ed

Please sign in to comment.