Fix double body read, improve logging

This commit is contained in:
Ian Gulliver
2025-08-20 23:00:10 -07:00
parent ccda5509b2
commit 9e9cceec20
2 changed files with 9 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"io"
"log"
"net/http"
)
@@ -48,6 +49,8 @@ func (pd *pdClient) sendAlert(msg string) error {
return err
}
log.Printf("[->pagerduty] %s", buf.String())
req, err := http.NewRequest("POST", "https://events.pagerduty.com/v2/enqueue", buf)
if err != nil {
return err
@@ -67,5 +70,7 @@ func (pd *pdClient) sendAlert(msg string) error {
return fmt.Errorf("%s", string(body))
}
log.Printf("[<-pagerduty] %s", string(body))
return nil
}