MM-11701 Log request ID for outgoing webhooks (#10513)
* "Log request ID" * "Log request ID" * "Update in response to comment" * "Update in response to comment" * "Run gofmt"
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
8d8a4d8614
Коммит
571a026a4e
@@ -4,7 +4,6 @@
|
|||||||
package web
|
package web
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -30,6 +29,15 @@ func incomingWebhook(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
var err *model.AppError
|
var err *model.AppError
|
||||||
incomingWebhookPayload := &model.IncomingWebhookRequest{}
|
incomingWebhookPayload := &model.IncomingWebhookRequest{}
|
||||||
contentType := r.Header.Get("Content-Type")
|
contentType := r.Header.Get("Content-Type")
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
if *c.App.Config().LogSettings.EnableWebhookDebugging {
|
||||||
|
if c.Err != nil {
|
||||||
|
mlog.Debug("Incoming webhook received", mlog.String("webhook_id", id), mlog.String("request_id", c.App.RequestId), mlog.String("payload", incomingWebhookPayload.ToJson()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
if strings.Split(contentType, "; ")[0] == "application/x-www-form-urlencoded" {
|
if strings.Split(contentType, "; ")[0] == "application/x-www-form-urlencoded" {
|
||||||
payload := strings.NewReader(r.FormValue("payload"))
|
payload := strings.NewReader(r.FormValue("payload"))
|
||||||
|
|
||||||
@@ -56,10 +64,6 @@ func incomingWebhook(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if *c.App.Config().LogSettings.EnableWebhookDebugging {
|
|
||||||
mlog.Debug(fmt.Sprintf("Incoming webhook received. Id=%s Content=%s", id, incomingWebhookPayload.ToJson()))
|
|
||||||
}
|
|
||||||
|
|
||||||
err = c.App.HandleIncomingWebhook(id, incomingWebhookPayload)
|
err = c.App.HandleIncomingWebhook(id, incomingWebhookPayload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Err = err
|
c.Err = err
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user