diff --git a/hook/hook.go b/hook/hook.go index 926a651..d5f43fa 100644 --- a/hook/hook.go +++ b/hook/hook.go @@ -290,17 +290,17 @@ func (h *ResponseHeaders) Set(value string) error { // Hook type is a structure containing details for a single hook type Hook struct { - ID string `json:"id,omitempty"` - ExecuteCommand string `json:"execute-command,omitempty"` - CommandWorkingDirectory string `json:"command-working-directory,omitempty"` - ResponseMessage string `json:"response-message,omitempty"` - ResponseHeaders ResponseHeaders `json:"response-headers,omitempty"` - CaptureCommandOutput bool `json:"include-command-output-in-response,omitempty"` - PassEnvironmentToCommand []Argument `json:"pass-environment-to-command,omitempty"` - PassArgumentsToCommand []Argument `json:"pass-arguments-to-command,omitempty"` - JSONStringParameters []Argument `json:"parse-parameters-as-json,omitempty"` - TriggerRule *Rules `json:"trigger-rule,omitempty"` - TriggerRuleMismatchCode int `json:"trigger-rule-mismatch-code,omitempty"` + ID string `json:"id,omitempty"` + ExecuteCommand string `json:"execute-command,omitempty"` + CommandWorkingDirectory string `json:"command-working-directory,omitempty"` + ResponseMessage string `json:"response-message,omitempty"` + ResponseHeaders ResponseHeaders `json:"response-headers,omitempty"` + CaptureCommandOutput bool `json:"include-command-output-in-response,omitempty"` + PassEnvironmentToCommand []Argument `json:"pass-environment-to-command,omitempty"` + PassArgumentsToCommand []Argument `json:"pass-arguments-to-command,omitempty"` + JSONStringParameters []Argument `json:"parse-parameters-as-json,omitempty"` + TriggerRule *Rules `json:"trigger-rule,omitempty"` + TriggerRuleMismatchHttpResponseCode int `json:"trigger-rule-mismatch-http-response-code,omitempty"` } // ParseJSONParameters decodes specified arguments to JSON objects and replaces the diff --git a/test/hooks.json.tmpl b/test/hooks.json.tmpl index c731c9a..0a8aead 100644 --- a/test/hooks.json.tmpl +++ b/test/hooks.json.tmpl @@ -4,7 +4,7 @@ "execute-command": "{{ .Hookecho }}", "command-working-directory": "/", "include-command-output-in-response": true, - "trigger-rule-mismatch-code": 400, + "trigger-rule-mismatch-http-response-code": 400, "pass-environment-to-command": [ { @@ -60,7 +60,7 @@ "command-working-directory": "/", "include-command-output-in-response": false, "response-message": "success", - "trigger-rule-mismatch-code": 999, + "trigger-rule-mismatch-http-response-code": 999, "parse-parameters-as-json": [ { "source": "payload", diff --git a/webhook.go b/webhook.go index 92f49b6..c3b0f4f 100644 --- a/webhook.go +++ b/webhook.go @@ -243,13 +243,13 @@ func hookHandler(w http.ResponseWriter, r *http.Request) { } // Check if a return code is configured for the hook - if matchedHook.TriggerRuleMismatchCode != 0 { + if matchedHook.TriggerRuleMismatchHttpResponseCode != 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) + if len(http.StatusText(matchedHook.TriggerRuleMismatchHttpResponseCode)) > 0 { + w.WriteHeader(matchedHook.TriggerRuleMismatchHttpResponseCode) } else { - log.Printf("%s got matched, but the configured return code %d is unknown - defaulting to 200\n", matchedHook.ID, matchedHook.TriggerRuleMismatchCode) + log.Printf("%s got matched, but the configured return code %d is unknown - defaulting to 200\n", matchedHook.ID, matchedHook.TriggerRuleMismatchHttpResponseCode) } }