mirror of
https://github.com/adnanh/webhook.git
synced 2025-05-14 09:34:43 +00:00
added flags
This commit is contained in:
parent
bacf2b3666
commit
b332c9e715
1 changed files with 17 additions and 1 deletions
18
webhook2.go
18
webhook2.go
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
@ -8,6 +9,21 @@ import (
|
||||||
"github.com/gorilla/mux"
|
"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() {
|
func main() {
|
||||||
router := mux.NewRouter()
|
router := mux.NewRouter()
|
||||||
router.HandleFunc("/hooks/{id}", hookHandler)
|
router.HandleFunc("/hooks/{id}", hookHandler)
|
||||||
|
@ -15,7 +31,7 @@ func main() {
|
||||||
n := negroni.Classic()
|
n := negroni.Classic()
|
||||||
n.UseHandler(router)
|
n.UseHandler(router)
|
||||||
|
|
||||||
n.Run(":9000")
|
n.Run(fmt.Sprintf("%s:%d", *ip, *port))
|
||||||
}
|
}
|
||||||
|
|
||||||
func hookHandler(w http.ResponseWriter, r *http.Request) {
|
func hookHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue