-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Comms: add http client common utilities and minor fixes
- Loading branch information
1 parent
76d9104
commit d25d356
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |