func (c *Client) Do(ctx context.Context, method, path string, body io.Reader, obj interface{}) error {

	resp, err := c.makeRequest(ctx, method, path, body)
	if err != nil {
		return err
	}

	defer resp.Body.Close()

	if resp.StatusCode >= 300 {
		message := new(bytes.Buffer)
		message.ReadFrom(resp.Body)
		msg := fmt.Sprintf("%s", message.String())
		return NewError(msg)
	}

	// Read all of resp.Body regardless of status code so we don't leak connections.
	// The extra io.Copy is to ensure everything has been read, since a json.Decoder doesn't
	// have that guarantee.
	if obj != nil {
		err = json.NewDecoder(resp.Body).Decode(obj)
	}

	io.Copy(ioutil.Discard, resp.Body)

	return err
}
// Do performs an HTTP request with a given context - the response will be decoded
// into obj.
Do performs an HTTP request with a given context - the response will be decoded
into obj.
// Do performs an HTTP request with a given context - the response will be decoded // into obj .
func (c *Client) Do(ctx context.Context, method, path string, body io.Reader, obj interface{}) error {
	resp, err := c.makeRequest(ctx, method, path, body)
	if err != nil {
		return err
	}
	defer resp.Body.Close()
	if resp.StatusCode >= 300 {
		message := new(bytes.Buffer)
		message.ReadFrom(resp.Body)
		msg := fmt.Sprintf("%s", message.String())
		return NewError(msg)
	}
	if obj != nil {
		err = json.NewDecoder(resp.Body).Decode(obj)
	}
	io.Copy(ioutil.Discard, resp.Body)
	return err
}
func ( c * Client ) Do ( ctx context . Context , method , path string , body io . Reader , obj interface { } ) error { resp , err := c . makeRequest ( ctx , method , path , body ) if err != nil { return err } defer resp . Body . Close ( ) if resp . StatusCode >= 300 { message := new ( bytes . Buffer ) message . ReadFrom ( resp . Body ) msg := fmt . Sprintf ( " " , message . String ( ) ) return NewError ( msg ) } if obj != nil { err = json . NewDecoder ( resp . Body ) . Decode ( obj ) } io . Copy ( ioutil . Discard , resp . Body ) return err }
Do performs an HTTP request with a given context - the response will be decoded
into obj.
Do performs an HTTP request with a given context - the response will be decoded into obj .
// Read all of resp.Body regardless of status code so we don't leak connections. // The extra io.Copy is to ensure everything has been read, since a json.Decoder doesn't // have that guarantee.