func (c Client) Do(req *http.Request) (io.ReadCloser, error) {
	if c.debug == true {
		d, err := httputil.DumpRequestOut(req, true)
		if err != nil {
			return nil, err
		}
		fmt.Printf("%s\n", d)
	}
	resp, err := c.httpClient.Do(req)
	if err != nil {
		return nil, err
	}
	if resp.StatusCode != 200 {
		body, err := ioutil.ReadAll(resp.Body)
		resp.Body.Close()
		if err != nil {
			return nil, fmt.Errorf("server returned %s\n", resp.Status)
		}
		return nil, fmt.Errorf("server returned %s\n%s\n", resp.Status, string(body))
	}
	return resp.Body, nil
}
Do executes a request against the Wavefront API.
The response body is returned if the request is successful, and should
be closed by the requester.
package wavefront
import (
	"bytes"
	"crypto/tls"
	"fmt"
	"io"
	"io/ioutil"
	"net/http"
	"net/http/httputil"
	"net/url"
	"time"
)
type Wavefronter interface {
	NewRequest(method, path string, params *map[string]string, body []byte) (*http.Request, error)
	Do(req *http.Request) (io.ReadCloser, error)
}
type Config struct {
	Address string
	Token string
	Timeout time.Duration
	TLSClientConfig *tls.Config
	HttpProxy string
	SkipTLSVerify bool
}
type Client struct {
	Config *Config
	BaseURL *url.URL
	httpClient *http.Client
	debug bool
}
func NewClient(config *Config) (*Client, error) {
	baseURL, err := url.Parse("https://" + config.Address + "/api/v2/")
	if err != nil {
		return nil, err
	}
	t := &http.Transport{
		TLSClientConfig: config.TLSClientConfig,
		TLSNextProto:    map[string]func(authority string, c *tls.Conn) http.RoundTripper{},
	}
	h := &http.Client{
		Timeout:   config.Timeout,
		Transport: t,
	}
	c := &Client{
		Config:     config,
		BaseURL:    baseURL,
		httpClient: h,
		debug:      false,
	}
	if config.HttpProxy != "" {
		proxyUrl, _ := url.Parse(config.HttpProxy)
		t.Proxy = http.ProxyURL(proxyUrl)
	}
	if config.SkipTLSVerify == true {
		tr := &http.Transport{
			TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
		}
		c.httpClient.Transport = tr
	}
	return c, nil
}
func (c Client) NewRequest(method, path string, params *map[string]string, body []byte) (*http.Request, error) {
	rel, err := url.Parse(path)
	if err != nil {
		return nil, err
	}
	url := c.BaseURL.ResolveReference(rel)
	if params != nil {
		q := url.Query()
		for k, v := range *params {
			q.Set(k, v)
		}
		url.RawQuery = q.Encode()
	}
	req, err := http.NewRequest(method, url.String(), nil)
	if err != nil {
		return nil, err
	}
	req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", c.Config.Token))
	req.Header.Add("Accept", "application/json")
	if body != nil {
		req.Header.Add("Content-Type", "application/json")
		req.Body = ioutil.NopCloser(bytes.NewReader(body))
	}
	return req, nil
}