func SendGet(url, user, password string) (*Response, error) {
	req := NewRequest(url, Get, nil, nil, nil)
	req.SetBasicAuth(user, password)
	resp, err := Send(req)
	if err != nil || resp.StatusCode != http.StatusOK {
		return nil, err
	}
	return resp, nil
}
SendGet send get http request
package requests
import (
	"bytes"
	"fmt"
	"io"
	"io/ioutil"
	"net"
	"net/http"
	"net/url"
	"sync/atomic"
	"time"
	"github.com/nooncall/shazam/log"
)
const (
	Get    string = "GET"
	Post   string = "POST"
	Put    string = "PUT"
	Patch  string = "PATCH"
	Delete string = "DELETE"
)
var defaultClient *http.Client
func init() {
	var dials uint64
	tr := &http.Transport{}
	tr.Dial = func(network, addr string) (net.Conn, error) {
		c, err := net.DialTimeout(network, addr, time.Second*10)
		if err == nil {
			log.Debug("rpc: dial new connection to %s， dials: %d", addr, atomic.AddUint64(&dials, 1)-1)
		}
		return c, err
	}
	defaultClient = &http.Client{
		Transport: tr,
		Timeout:   time.Second * 30,
	}
	go func() {
		for {
			time.Sleep(time.Minute)
			tr.CloseIdleConnections()
		}
	}()
}
type Request struct {
	User     string
	Password string
	Method   string
	URL      string
	Header   map[string]string
	Params   map[string]string
	Body     []byte
}
func NewRequest(url, method string, header map[string]string, params map[string]string, data []byte) *Request {
	return &Request{Method: method, URL: url, Header: header, Params: params, Body: data}
}
func (req *Request) SetBasicAuth(user, password string) {
	req.User = user
	req.Password = password
}
type Response struct {
	StatusCode int
	Header     map[string][]string
	Body       []byte
}
func AddParameters(baseURL string, queryParams map[string]string) string {
	baseURL += "?"
	params := url.Values{}
	for key, value := range queryParams {
		params.Add(key, value)
	}
	return baseURL + params.Encode()
}
func BuildHTTPRequest(request *Request) (*http.Request, error) {
	if len(request.Params) > 0 {
		request.URL = AddParameters(request.URL, request.Params)
	}
	httpReq, err := http.NewRequest(request.Method, request.URL, bytes.NewReader(request.Body))
	if err != nil {
		return nil, err
	}
	if request.User != "" && request.Password != "" {
		httpReq.SetBasicAuth(request.User, request.Password)
	}
	for k, v := range request.Header {
		httpReq.Header.Set(k, v)
	}
	_, ok := request.Header["Content-Type"]
	if len(request.Body) > 0 && !ok {
		httpReq.Header.Set("Content-Type", "application/json")
	}
	return httpReq, nil
}
func buildResponse(res *http.Response) (*Response, error) {
	body, err := ioutil.ReadAll(res.Body)
	if err != nil {
		return nil, err
	}
	r := &Response{
		StatusCode: res.StatusCode,
		Body:       body,
		Header:     res.Header,
	}
	return r, nil
}
func Send(request *Request) (*Response, error) {
	var start = time.Now()
	httpReq, err := BuildHTTPRequest(request)
	if err != nil {
		return nil, err
	}
	rsp, err := defaultClient.Do(httpReq)
	if err != nil {
		return nil, err
	}
	defer func() {
		io.Copy(ioutil.Discard, rsp.Body)
		rsp.Body.Close()
		log.Debug("call rpc [%s] %s in %v", httpReq.Method, httpReq.URL, time.Since(start))
	}()
	r, err := buildResponse(rsp)
	return r, err
}
func SendPut(url, user, password string) error {
	req := NewRequest(url, Put, nil, nil, nil)
	req.SetBasicAuth(user, password)
	_, err := Send(req)
	return err
}