Implement Slack alerting (#2)

This commit is contained in:
TwinProduction
2020-08-20 21:11:22 -04:00
parent 6596d253aa
commit 6f4cf69c4e
3 changed files with 40 additions and 2 deletions

View File

@ -13,8 +13,8 @@ type requestBody struct {
}
// SendSlackMessage sends a message to the given Slack webhook
func SendSlackMessage(webhookUrl, msg string) error {
body, _ := json.Marshal(requestBody{Text: msg})
func SendSlackMessage(webhookUrl, service, description string) error {
body, _ := json.Marshal(requestBody{Text: fmt.Sprintf("*[Gatus]*\n*service:* %s\n*description:* %s", service, description)})
response, err := client.GetHttpClient().Post(webhookUrl, "application/json", bytes.NewBuffer(body))
if err != nil {
return err