Files
cachet-monitor/cachet/request.go
Matej Kramny d421b35e9b gofmt -w
2015-03-20 20:58:56 +01:00

26 lines
543 B
Go

package cachet
import (
"bytes"
"io/ioutil"
"net/http"
)
func makeRequest(requestType string, url string, reqBody []byte) (*http.Response, []byte, error) {
req, err := http.NewRequest(requestType, Config.APIUrl+url, bytes.NewBuffer(reqBody))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-Cachet-Token", Config.APIToken)
client := &http.Client{}
res, err := client.Do(req)
if err != nil {
return nil, []byte{}, err
}
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
return res, body, nil
}