From 8be9030703cfaa52f8fee2ace5754599092cb252 Mon Sep 17 00:00:00 2001
From: ale <ale@incal.net>
Date: Thu, 7 Dec 2017 11:12:28 +0000
Subject: [PATCH] Pass a Context do DoJSONHTTPRequest

---
 clientutil/json.go | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/clientutil/json.go b/clientutil/json.go
index 862d086..5fc1ab2 100644
--- a/clientutil/json.go
+++ b/clientutil/json.go
@@ -2,13 +2,17 @@ package clientutil
 
 import (
 	"bytes"
+	"context"
 	"encoding/json"
 	"errors"
 	"fmt"
 	"net/http"
 )
 
-func DoJSONHTTPRequest(client *http.Client, uri string, req, resp interface{}) error {
+// DoJSONHTTPRequest makes an HTTP POST request to the specified uri,
+// with a JSON-encoded request body. It will attempt to decode the
+// response body as JSON.
+func DoJSONHTTPRequest(ctx context.Context, client *http.Client, uri string, req, resp interface{}) error {
 	data, err := json.Marshal(req)
 	if err != nil {
 		return err
@@ -19,6 +23,7 @@ func DoJSONHTTPRequest(client *http.Client, uri string, req, resp interface{}) e
 		return err
 	}
 	httpReq.Header.Set("Content-Type", "application/json")
+	httpReq = httpReq.WithContext(ctx)
 
 	httpResp, err := RetryHTTPDo(client, httpReq, NewExponentialBackOff())
 	if err != nil {
-- 
GitLab