mirror of
https://github.com/adnanh/webhook.git
synced 2025-05-23 05:42:30 +00:00
Add HTTP methods cli parameter
Allows to globally restrict HTTP methods. Fixes #248
This commit is contained in:
parent
3414f34025
commit
c38778ba62
3 changed files with 34 additions and 12 deletions
|
@ -50,6 +50,7 @@ var (
|
|||
maxMultipartMem = flag.Int64("max-multipart-mem", 1<<20, "maximum memory in bytes for parsing multipart form data before disk caching")
|
||||
setGID = flag.Int("setgid", 0, "set group ID after opening listening port; must be used with setuid")
|
||||
setUID = flag.Int("setuid", 0, "set user ID after opening listening port; must be used with setgid")
|
||||
httpMethods = flag.String("http-methods", "", "globally restrict allowed HTTP methods; separate methods with comma")
|
||||
|
||||
responseHeaders hook.ResponseHeaders
|
||||
hooksFiles hook.HooksFiles
|
||||
|
@ -203,7 +204,12 @@ func main() {
|
|||
fmt.Fprint(w, "OK")
|
||||
})
|
||||
|
||||
r.HandleFunc(hooksURL, hookHandler)
|
||||
if *httpMethods == "" {
|
||||
r.HandleFunc(hooksURL, hookHandler)
|
||||
} else {
|
||||
allowed := strings.Split(*httpMethods, ",")
|
||||
r.HandleFunc(hooksURL, hookHandler).Methods(allowed...)
|
||||
}
|
||||
|
||||
addr := fmt.Sprintf("%s:%d", *ip, *port)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue