|
@@ -41,19 +41,28 @@ func (h *WebhookHandler) HandleWebhook(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
|
|
|
matchingActions := h.findMatchingActions(r, payload)
|
|
matchingActions := h.findMatchingActions(r, payload)
|
|
|
if len(matchingActions) == 0 {
|
|
if len(matchingActions) == 0 {
|
|
|
|
|
+ log.WithFields(webhookRequestFields(r)).Infof("Webhook: no matching actions")
|
|
|
h.writeOKResponse(w, "no matching webhook actions")
|
|
h.writeOKResponse(w, "no matching webhook actions")
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
processed := h.processMatchingActions(matchingActions, r, payload)
|
|
processed := h.processMatchingActions(matchingActions, r, payload)
|
|
|
- log.WithFields(log.Fields{
|
|
|
|
|
|
|
+ log.WithFields(webhookRequestFields(r)).WithFields(log.Fields{
|
|
|
"matched": len(matchingActions),
|
|
"matched": len(matchingActions),
|
|
|
"processed": processed,
|
|
"processed": processed,
|
|
|
- }).Infof("Webhook processed")
|
|
|
|
|
|
|
+ }).Infof("Webhook: matched")
|
|
|
|
|
|
|
|
h.writeOKResponse(w, "webhook actions")
|
|
h.writeOKResponse(w, "webhook actions")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func webhookRequestFields(r *http.Request) log.Fields {
|
|
|
|
|
+ return log.Fields{
|
|
|
|
|
+ "method": r.Method,
|
|
|
|
|
+ "path": r.URL.Path,
|
|
|
|
|
+ "query": r.URL.RawQuery,
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
func (h *WebhookHandler) readPayload(r *http.Request) ([]byte, error) {
|
|
func (h *WebhookHandler) readPayload(r *http.Request) ([]byte, error) {
|
|
|
maxSize := int64(1024 * 1024)
|
|
maxSize := int64(1024 * 1024)
|
|
|
payload, err := io.ReadAll(io.LimitReader(r.Body, maxSize))
|
|
payload, err := io.ReadAll(io.LimitReader(r.Body, maxSize))
|