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:
26
webhook.go
Normal file
26
webhook.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user