]> source.dussan.org Git - gitea.git/commitdiff
Fix broken webhooks (#29690)
authorLunny Xiao <xiaolunwen@gmail.com>
Sun, 10 Mar 2024 01:32:48 +0000 (09:32 +0800)
committerGitHub <noreply@github.com>
Sun, 10 Mar 2024 01:32:48 +0000 (01:32 +0000)
Fix #29689

services/webhook/payloader.go

index abf9946cca47f755ddf485074b9221d5c664fd6a..54a11a58682d2530bc60a90dd0b757dd82adda53 100644 (file)
@@ -94,7 +94,12 @@ func newJSONRequest[T any](pc payloadConvertor[T], w *webhook_model.Webhook, t *
                return nil, nil, err
        }
 
-       req, err := http.NewRequest(w.HTTPMethod, w.URL, bytes.NewReader(body))
+       method := w.HTTPMethod
+       if method == "" {
+               method = http.MethodPost
+       }
+
+       req, err := http.NewRequest(method, w.URL, bytes.NewReader(body))
        if err != nil {
                return nil, nil, err
        }