From 1fdd82f99eff46821323380019bbf7a66a60d37b Mon Sep 17 00:00:00 2001 From: Vilen Topchii <32271530+vtopc@users.noreply.github.com> Date: Tue, 3 Dec 2024 20:54:25 +0200 Subject: [PATCH] DE-1143 Use http constants (#356) --- events.go | 3 ++- exports.go | 2 +- webhooks_test.go | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/events.go b/events.go index ad875964..efd75b1d 100644 --- a/events.go +++ b/events.go @@ -3,6 +3,7 @@ package mailgun import ( "context" "fmt" + "net/http" "time" jsoniter "github.com/json-iterator/go" @@ -163,7 +164,7 @@ func (ei *EventIterator) fetch(ctx context.Context, url string) error { r.setClient(ei.mg.Client()) r.setBasicAuth(basicAuthUser, ei.mg.APIKey()) - resp, err := makeRequest(ctx, r, "GET", nil) + resp, err := makeRequest(ctx, r, http.MethodGet, nil) if err != nil { return err } diff --git a/exports.go b/exports.go index 5b94ab2a..75cc8e37 100644 --- a/exports.go +++ b/exports.go @@ -76,7 +76,7 @@ func (mg *MailgunImpl) GetExportLink(ctx context.Context, id string) (string, er r.addHeader("User-Agent", MailgunGoUserAgent) - req, err := r.NewRequest(ctx, "GET", nil) + req, err := r.NewRequest(ctx, http.MethodGet, nil) if err != nil { return "", err } diff --git a/webhooks_test.go b/webhooks_test.go index add8f8df..aac3a596 100644 --- a/webhooks_test.go +++ b/webhooks_test.go @@ -141,7 +141,7 @@ func buildFormRequest(fields map[string]string) *http.Request { } r := strings.NewReader(values.Encode()) - req, _ := http.NewRequest("POST", "/", r) + req, _ := http.NewRequest(http.MethodPost, "/", r) req.Header.Set("Content-Type", "application/x-www-form-urlencoded") return req @@ -157,7 +157,7 @@ func buildMultipartFormRequest(fields map[string]string) *http.Request { writer.Close() - req, _ := http.NewRequest("POST", "/", buf) + req, _ := http.NewRequest(http.MethodPost, "/", buf) req.Header.Set("Content-type", writer.FormDataContentType()) return req