diff --git a/webhook2.go b/webhook2.go index d19a78c..372cdfa 100644 --- a/webhook2.go +++ b/webhook2.go @@ -1,6 +1,7 @@ package main import ( + "flag" "fmt" "net/http" @@ -8,6 +9,21 @@ import ( "github.com/gorilla/mux" ) +var ( + ip = flag.String("ip", "", "ip the webhook should serve hooks on") + port = flag.Int("port", 9000, "port the webhook should serve hooks on") + verbose = flag.Bool("verbose", false, "show verbose output") + hooksFilePath = flag.String("hooks", "hooks.json", "path to the json file containing defined hooks the webhook should serve") +) + +func init() { + flag.Parse() + + // load and parse hooks + + // set up file watcher +} + func main() { router := mux.NewRouter() router.HandleFunc("/hooks/{id}", hookHandler) @@ -15,7 +31,7 @@ func main() { n := negroni.Classic() n.UseHandler(router) - n.Run(":9000") + n.Run(fmt.Sprintf("%s:%d", *ip, *port)) } func hookHandler(w http.ResponseWriter, r *http.Request) {