mirror of
https://github.com/adnanh/webhook.git
synced 2025-08-02 16:00:30 +00:00
make http return code for mismatched rules configurable
Signed-off-by: Mathias Merscher <Mathias.Merscher@dg-i.net>
This commit is contained in:
parent
8226d5e50f
commit
ddb1f2441a
4 changed files with 20 additions and 1 deletions
11
webhook.go
11
webhook.go
|
@ -242,6 +242,17 @@ func hookHandler(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
// Check if a return code is configured for the hook
|
||||
if matchedHook.TriggerRuleMismatchCode != 0 {
|
||||
// Check if the configured return code is supported by the http package
|
||||
// by testing if there is a StatusText for this code.
|
||||
if len(http.StatusText(matchedHook.TriggerRuleMismatchCode)) > 0 {
|
||||
w.WriteHeader(matchedHook.TriggerRuleMismatchCode)
|
||||
} else {
|
||||
log.Printf("%s got matched, but the configured return code %d is unknown - defaulting to 200\n", matchedHook.ID, matchedHook.TriggerRuleMismatchCode)
|
||||
}
|
||||
}
|
||||
|
||||
// if none of the hooks got triggered
|
||||
log.Printf("%s got matched, but didn't get triggered because the trigger rules were not satisfied\n", matchedHook.ID)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue