Skip to content

Commit

Permalink
Merge pull request #32 from develar/http-with-context
Browse files Browse the repository at this point in the history
simplify code — use NewRequestWithContext API to create request
  • Loading branch information
thrawn01 authored Oct 4, 2021
2 parents 2fc526b + a6ecc94 commit 144bfc1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@ language: go
go_import_path: github.com/mailgun/groupcache

os: linux
dist: trusty
dist: xenial
sudo: false

script:
- go test ./...

go:
- 1.10.x
- 1.11.x
- 1.12.x
- 1.13.x
- 1.14.x
- 1.15.x
- 1.17.x
- master

cache:
Expand Down
5 changes: 1 addition & 4 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,11 @@ func (h *httpGetter) makeRequest(ctx context.Context, method string, in *pb.GetR
url.QueryEscape(in.GetGroup()),
url.QueryEscape(in.GetKey()),
)
req, err := http.NewRequest(method, u, nil)
req, err := http.NewRequestWithContext(ctx, method, u, nil)
if err != nil {
return err
}

// Pass along the context to the RoundTripper
req = req.WithContext(ctx)

tr := http.DefaultTransport
if h.getTransport != nil {
tr = h.getTransport(ctx)
Expand Down

0 comments on commit 144bfc1

Please sign in to comment.