From 4e186fe2b219e0278100b31fcc1e992185718bc2 Mon Sep 17 00:00:00 2001 From: an Date: Sun, 22 Apr 2018 15:44:35 +0200 Subject: [PATCH] read webhooks from file --- modules/webhook.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/webhook.go b/modules/webhook.go index acc4117..4a878ce 100644 --- a/modules/webhook.go +++ b/modules/webhook.go @@ -8,6 +8,7 @@ import ( "flag" "fmt" "net/http" + "os" "strings" "git.dnix.de/an/xlog" @@ -25,7 +26,12 @@ func init() { } func webhookRun() { - scanner := bufio.NewScanner(*webhookToken) + file, err := os.Open(*webhookToken) + if err != nil { + xlog.Fatal(err.Error()) + } + defer file.Close() + scanner := bufio.NewScanner(file) for scanner.Scan() { tok := strings.Split(scanner.Text(), " ") http.HandleFunc("/webhook/"+tok[0], webhookHandleHTTP)