From fa3e84444feb3547d0e3463ebc7c4a007709bc56 Mon Sep 17 00:00:00 2001 From: yohfee Date: Mon, 13 Nov 2023 18:45:50 +0900 Subject: [PATCH] Replace other HTTP method literals --- mackerel.go | 12 ++++++------ mackerel_test.go | 16 ++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/mackerel.go b/mackerel.go index f0e8d58..13b6b30 100644 --- a/mackerel.go +++ b/mackerel.go @@ -131,27 +131,27 @@ func (c *Client) Request(req *http.Request) (resp *http.Response, err error) { } func requestGet[T any](client *Client, path string) (*T, error) { - return requestNoBody[T](client, "GET", path, nil) + return requestNoBody[T](client, http.MethodGet, path, nil) } func requestGetWithParams[T any](client *Client, path string, params url.Values) (*T, error) { - return requestNoBody[T](client, "GET", path, params) + return requestNoBody[T](client, http.MethodGet, path, params) } func requestGetAndReturnHeader[T any](client *Client, path string) (*T, http.Header, error) { - return requestInternal[T](client, "GET", path, nil, nil) + return requestInternal[T](client, http.MethodGet, path, nil, nil) } func requestPost[T any](client *Client, path string, payload any) (*T, error) { - return requestJSON[T](client, "POST", path, payload) + return requestJSON[T](client, http.MethodPost, path, payload) } func requestPut[T any](client *Client, path string, payload any) (*T, error) { - return requestJSON[T](client, "PUT", path, payload) + return requestJSON[T](client, http.MethodPut, path, payload) } func requestDelete[T any](client *Client, path string) (*T, error) { - return requestNoBody[T](client, "DELETE", path, nil) + return requestNoBody[T](client, http.MethodDelete, path, nil) } func requestJSON[T any](client *Client, method, path string, payload any) (*T, error) { diff --git a/mackerel_test.go b/mackerel_test.go index 5fd1441..c26f43d 100644 --- a/mackerel_test.go +++ b/mackerel_test.go @@ -40,14 +40,14 @@ func Test_requestInternal(t *testing.T) { body io.Reader hasContentTypeHeader bool }{ - {"GET", nil, false}, - {"POST", nil, true}, - {"PUT", nil, true}, - {"DELETE", nil, true}, - {"GET", strings.NewReader("some"), true}, - {"POST", strings.NewReader("some"), true}, - {"PUT", strings.NewReader("some"), true}, - {"DELETE", strings.NewReader("some"), true}, + {http.MethodGet, nil, false}, + {http.MethodPost, nil, true}, + {http.MethodPut, nil, true}, + {http.MethodDelete, nil, true}, + {http.MethodGet, strings.NewReader("some"), true}, + {http.MethodPost, strings.NewReader("some"), true}, + {http.MethodPut, strings.NewReader("some"), true}, + {http.MethodDelete, strings.NewReader("some"), true}, } for _, test := range tests { t.Run(fmt.Sprintf("%s with %v body", test.method, test.body), func(tt *testing.T) {