mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
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"
This commit is contained in:
committed by
Christopher Speller
parent
8d8a4d8614
commit
571a026a4e
@@ -4,7 +4,6 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
@@ -30,6 +29,15 @@ func incomingWebhook(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
var err *model.AppError
|
||||
incomingWebhookPayload := &model.IncomingWebhookRequest{}
|
||||
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" {
|
||||
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)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
|
||||
Reference in New Issue
Block a user