mirror of
https://github.com/adnanh/webhook.git
synced 2025-05-11 16:14:52 +00:00
Merge pull request #206 from dcj/feature/incoming-payload-content-type
added support for incoming-payload-content-type
This commit is contained in:
commit
f9e799fea0
2 changed files with 5 additions and 0 deletions
|
@ -426,6 +426,7 @@ type Hook struct {
|
|||
JSONStringParameters []Argument `json:"parse-parameters-as-json,omitempty"`
|
||||
TriggerRule *Rules `json:"trigger-rule,omitempty"`
|
||||
TriggerRuleMismatchHttpResponseCode int `json:"trigger-rule-mismatch-http-response-code,omitempty"`
|
||||
IncomingPayloadContentType string `json:"incoming-payload-content-type,omitempty"`
|
||||
}
|
||||
|
||||
// ParseJSONParameters decodes specified arguments to JSON objects and replaces the
|
||||
|
|
|
@ -229,7 +229,11 @@ func hookHandler(w http.ResponseWriter, r *http.Request) {
|
|||
// parse body
|
||||
var payload map[string]interface{}
|
||||
|
||||
// set contentType to IncomingPayloadContentType or header value
|
||||
contentType := r.Header.Get("Content-Type")
|
||||
if len(matchedHook.IncomingPayloadContentType) != 0 {
|
||||
contentType = matchedHook.IncomingPayloadContentType
|
||||
}
|
||||
|
||||
if strings.Contains(contentType, "json") {
|
||||
decoder := json.NewDecoder(strings.NewReader(string(body)))
|
||||
|
|
Loading…
Add table
Reference in a new issue