read webhooks from file

This commit is contained in:
an 2018-04-22 15:44:35 +02:00
parent 66c4eecfda
commit 4e186fe2b2
1 changed files with 7 additions and 1 deletions

View File

@ -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)