Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Client *http.Client
Client stores a HTTP client, so that it doesn't need to be initialised on every request
View Source
var HTTPNewRequest = http.NewRequest
HTTPNewRequest stores http.NewRequest, which can be substituted in unit tests
View Source
var MakeRequest = func(method string, url string, headers map[string]string, body []byte) (*http.Response, error) { var ( response *http.Response count int = 0 ) request, err := HTTPNewRequest(method, url, bytes.NewBuffer(body)) if err != nil { return nil, err } for k, v := range headers { request.Header.Set(k, v) } for count == 0 || (err != nil && count < 3) { response, err = Client.Do(request) count++ } if err != nil { return nil, err } if response.StatusCode >= 400 { err = errors.New(strconv.Itoa(response.StatusCode)) return nil, err } return response, err }
MakeRequest builds an authenticated HTTP client which sends HTTP requests and parses the responses
Functions ¶
func InitialiseClient ¶
InitialiseClient sets up an HTTP client and returns it
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.