3
0
mirror of https://kolaente.dev/konrad/docker-db-backup.git synced 2026-01-10 02:50:08 +01:00

feat: add completion webhook url

This commit is contained in:
kolaente
2023-06-05 18:35:21 +02:00
parent e43e8c3959
commit 07c2fae209
4 changed files with 46 additions and 3 deletions

26
webhook.go Normal file
View File

@@ -0,0 +1,26 @@
package main
import (
"bytes"
"fmt"
"net/http"
)
func callWebhook() error {
if config.CompletionWebhookURL == "" {
return nil
}
res, err := http.Get(config.CompletionWebhookURL)
if err != nil {
return err
}
if res.StatusCode > 399 {
buf := bytes.Buffer{}
_, _ = buf.ReadFrom(res.Body)
return fmt.Errorf("recived an error status code while calling the webhook: %d, message: %s", res.StatusCode, buf.String())
}
return nil
}