Improve incoming webhook slack compatibility (#2972) (#2973)

By checking for form urlencoded content instead of JSON, requests without
or with a wrong Content-Type header and a JSON body are correctly parsed.
Этот коммит содержится в:
thoemy
2016-05-12 13:44:44 +02:00
коммит произвёл Christopher Speller
родитель 97450762db
Коммит 04dfa2a9eb

Просмотреть файл

@@ -358,10 +358,10 @@ func incomingWebhook(c *Context, w http.ResponseWriter, r *http.Request) {
var parsedRequest *model.IncomingWebhookRequest
contentType := r.Header.Get("Content-Type")
if strings.Split(contentType, "; ")[0] == "application/json" {
parsedRequest = model.IncomingWebhookRequestFromJson(r.Body)
} else {
if strings.Split(contentType, "; ")[0] == "application/x-www-form-urlencoded" {
parsedRequest = model.IncomingWebhookRequestFromJson(strings.NewReader(r.FormValue("payload")))
} else {
parsedRequest = model.IncomingWebhookRequestFromJson(r.Body)
}
if parsedRequest == nil {