Пример #1
0
// makeGetRequest shim performs a GET request, checking for a positive outcome.
// See simplehttp.MakeGetRequest for more details.
func makeGetRequest(r *simplehttp.HTTPRequest) (*simplehttp.HTTPResponse, error) {
	r.AddHeader("User-Agent", MailgunGoUserAgent)
	rsp, err := r.MakeGetRequest()
	if (err == nil) && notGood(rsp.Code, expected) {
		return rsp, newError(r.URL, expected, rsp.Code)
	}
	return rsp, err
}
Пример #2
0
// getResponseFromJSON shim performs a GET request, checking for a positive outcome.
// See simplehttp.GetResponseFromJSON for more details.
func getResponseFromJSON(r *simplehttp.HTTPRequest, v interface{}) error {
	r.AddHeader("User-Agent", MailgunGoUserAgent)
	response, err := r.MakeGetRequest()
	if err != nil {
		return err
	}
	if notGood(response.Code, expected) {
		return newError(r.URL, expected, response.Code)
	}
	return response.ParseFromJSON(v)
}