returning error from notification sendJson for debugging
This commit is contained in:
parent
64cd7cdf6a
commit
d0afc3df94
1 changed files with 6 additions and 2 deletions
|
@ -105,11 +105,14 @@ func getBuildUrl(context *model.Request) string {
|
||||||
|
|
||||||
// helper fuction to sent HTTP Post requests
|
// helper fuction to sent HTTP Post requests
|
||||||
// with JSON data as the payload.
|
// with JSON data as the payload.
|
||||||
func sendJson(url string, payload []byte, headers map[string]string) {
|
func sendJson(url string, payload []byte, headers map[string]string) error {
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
buf := bytes.NewBuffer(payload)
|
buf := bytes.NewBuffer(payload)
|
||||||
|
|
||||||
req, err := http.NewRequest("POST", url, buf)
|
req, err := http.NewRequest("POST", url, buf)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
req.Header.Set("Content-Type", "application/json")
|
req.Header.Set("Content-Type", "application/json")
|
||||||
if headers != nil {
|
if headers != nil {
|
||||||
|
@ -120,7 +123,8 @@ func sendJson(url string, payload []byte, headers map[string]string) {
|
||||||
|
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue