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.
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
97450762db
Коммит
04dfa2a9eb
@@ -358,10 +358,10 @@ func incomingWebhook(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
var parsedRequest *model.IncomingWebhookRequest
|
var parsedRequest *model.IncomingWebhookRequest
|
||||||
contentType := r.Header.Get("Content-Type")
|
contentType := r.Header.Get("Content-Type")
|
||||||
if strings.Split(contentType, "; ")[0] == "application/json" {
|
if strings.Split(contentType, "; ")[0] == "application/x-www-form-urlencoded" {
|
||||||
parsedRequest = model.IncomingWebhookRequestFromJson(r.Body)
|
|
||||||
} else {
|
|
||||||
parsedRequest = model.IncomingWebhookRequestFromJson(strings.NewReader(r.FormValue("payload")))
|
parsedRequest = model.IncomingWebhookRequestFromJson(strings.NewReader(r.FormValue("payload")))
|
||||||
|
} else {
|
||||||
|
parsedRequest = model.IncomingWebhookRequestFromJson(r.Body)
|
||||||
}
|
}
|
||||||
|
|
||||||
if parsedRequest == nil {
|
if parsedRequest == nil {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user