Skip to content

Commit

Permalink
added custom url prefix for served hooks url path
Browse files Browse the repository at this point in the history
  • Loading branch information
adnanh committed Mar 17, 2015
1 parent 37b310f commit 5a96a57
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,19 @@ import (
)

const (
version = "2.2.0"
version = "2.2.1"
)

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")
hotReload = flag.Bool("hotreload", false, "watch hooks file for changes and reload them automatically")
hooksFilePath = flag.String("hooks", "hooks.json", "path to the json file containing defined hooks the webhook should serve")
secure = flag.Bool("secure", false, "use HTTPS instead of HTTP")
cert = flag.String("cert", "cert.pem", "path to the HTTPS certificate pem file")
key = flag.String("key", "key.pem", "path to the HTTPS certificate private key pem file")
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")
hotReload = flag.Bool("hotreload", false, "watch hooks file for changes and reload them automatically")
hooksFilePath = flag.String("hooks", "hooks.json", "path to the json file containing defined hooks the webhook should serve")
hooksURLPrefix = flag.String("urlprefix", "hooks", "url prefix to use for served hooks (protocol://yourserver:port/PREFIX/:hook-id)")
secure = flag.Bool("secure", false, "use HTTPS instead of HTTP")
cert = flag.String("cert", "cert.pem", "path to the HTTPS certificate pem file")
key = flag.String("key", "key.pem", "path to the HTTPS certificate private key pem file")

watcher *fsnotify.Watcher

Expand Down Expand Up @@ -106,7 +107,16 @@ func main() {
n := negroni.New(negroniRecovery, negroniLogger)

router := mux.NewRouter()
router.HandleFunc("/hooks/{id}", hookHandler)

var hooksURL string

if *hooksURLPrefix == "" {
hooksURL = "/{id}"
} else {
hooksURL = "/" + *hooksURLPrefix + "/{id}"
}

router.HandleFunc(hooksURL, hookHandler)

n.UseHandler(router)

Expand Down

0 comments on commit 5a96a57

Please sign in to comment.