read webhooks from file
This commit is contained in:
		
							parent
							
								
									66c4eecfda
								
							
						
					
					
						commit
						4e186fe2b2
					
				
					 1 changed files with 7 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue