added flags

This commit is contained in:
Adnan Hajdarevic 2015-03-11 17:08:53 +01:00
parent bacf2b3666
commit b332c9e715

View file

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