Using context for HTTP requests

This commit is contained in:
Quentin McGaw
2020-10-17 21:54:09 +00:00
parent 0d2ca377df
commit 6f4be72785
7 changed files with 37 additions and 28 deletions

View File

@@ -16,6 +16,7 @@ import (
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/golibs/files"
"github.com/qdm12/golibs/logging"
"golang.org/x/net/context/ctxhttp"
)
type piaV3 struct {
@@ -89,7 +90,7 @@ func (p *piaV3) PortForward(ctx context.Context, client *http.Client,
}
clientID := hex.EncodeToString(b)
url := fmt.Sprintf("%s/?client_id=%s", constants.PIAPortForwardURL, clientID)
response, err := client.Get(url) // TODO add ctx
response, err := ctxhttp.Get(ctx, client, url)
if err != nil {
pfLogger.Error(err)
return