Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit 740521c

Browse files
authored
Merge pull request #173 from optman/master
http api to support cancel
2 parents 2633719 + 4ecd1fa commit 740521c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

request.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
)
1717

1818
type Request struct {
19+
Ctx context.Context
1920
ApiBase string
2021
Command string
2122
Args []string
@@ -34,6 +35,7 @@ func NewRequest(ctx context.Context, url, command string, args ...string) *Reque
3435
"stream-channels": "true",
3536
}
3637
return &Request{
38+
Ctx: ctx,
3739
ApiBase: url + "/api/v0",
3840
Command: command,
3941
Args: args,
@@ -113,6 +115,8 @@ func (r *Request) Send(c *http.Client) (*Response, error) {
113115
return nil, err
114116
}
115117

118+
req = req.WithContext(r.Ctx)
119+
116120
// Add any headers that were supplied via the RequestBuilder.
117121
for k, v := range r.Headers {
118122
req.Header.Add(k, v)

0 commit comments

Comments
 (0)