From 5f503eb56cafe4dc449f8a06d66bde1baa735e23 Mon Sep 17 00:00:00 2001 From: "manu.somolinos" Date: Mon, 5 Jul 2021 15:54:14 +0200 Subject: [PATCH] Comms: add http client common utilities and minor fixes --- comms/httpClient.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 comms/httpClient.go diff --git a/comms/httpClient.go b/comms/httpClient.go new file mode 100644 index 0000000..d8ecaf4 --- /dev/null +++ b/comms/httpClient.go @@ -0,0 +1,22 @@ +package comms + +import ( + "io" + "net/http" +) + +type HttpClient struct { + Client *http.Client +} + +func NewHttpClient(client *http.Client) *HttpClient { + return &HttpClient{Client: client} +} + +func (httpClient *HttpClient) GetRequest(method string, url string, body io.Reader) (*http.Request, error) { + return http.NewRequest(method, url, body) +} + +func (httpClient *HttpClient) DoRequest(r *http.Request) (*http.Response, error) { + return httpClient.Client.Do(r) +}