mirror of https://github.com/statping/statping
webhook notifier fix
parent
158c53f56a
commit
c3a85e3d7f
|
@ -82,12 +82,8 @@ func (w *webhooker) Select() *notifications.Notification {
|
||||||
func (w *webhooker) sendHttpWebhook(body string) (*http.Response, error) {
|
func (w *webhooker) sendHttpWebhook(body string) (*http.Response, error) {
|
||||||
utils.Log.Infoln(fmt.Sprintf("sending body: '%v' to %v as a %v request", body, w.Host, w.Var1))
|
utils.Log.Infoln(fmt.Sprintf("sending body: '%v' to %v as a %v request", body, w.Host, w.Var1))
|
||||||
client := new(http.Client)
|
client := new(http.Client)
|
||||||
client.Timeout = time.Duration(10 * time.Second)
|
client.Timeout = 10 * time.Second
|
||||||
buf := bytes.NewBuffer(nil)
|
req, err := http.NewRequest(w.Var1, w.Host, bytes.NewBufferString(body))
|
||||||
if w.Var2 != "" {
|
|
||||||
buf = bytes.NewBuffer([]byte(body))
|
|
||||||
}
|
|
||||||
req, err := http.NewRequest(w.Var1, w.Host, buf)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -100,6 +96,8 @@ func (w *webhooker) sendHttpWebhook(body string) (*http.Response, error) {
|
||||||
}
|
}
|
||||||
if w.ApiKey != "" {
|
if w.ApiKey != "" {
|
||||||
req.Header.Add("Content-Type", w.ApiKey)
|
req.Header.Add("Content-Type", w.ApiKey)
|
||||||
|
} else {
|
||||||
|
req.Header.Add("Content-Type", "application/json")
|
||||||
}
|
}
|
||||||
req.Header.Set("User-Agent", "Statping")
|
req.Header.Set("User-Agent", "Statping")
|
||||||
req.Header.Set("Statping-Version", utils.Version)
|
req.Header.Set("Statping-Version", utils.Version)
|
||||||
|
|
Loading…
Reference in New Issue