diff --git a/cmd/faucet/faucet.go b/cmd/faucet/faucet.go index 0d94389243d6..36388d79962a 100644 --- a/cmd/faucet/faucet.go +++ b/cmd/faucet/faucet.go @@ -657,7 +657,7 @@ func sendSuccess(conn *wsConn, msg string) error { func authGitHub(url string) (string, string, common.Address, error) { // Retrieve the gist from the GitHub Gist APIs parts := strings.Split(url, "/") - req, _ := http.NewRequest("GET", "https://api.github.com/gists/"+parts[len(parts)-1], nil) + req, _ := http.NewRequest(http.MethodGet, "https://api.github.com/gists/"+parts[len(parts)-1], nil) if *githubUser != "" { req.SetBasicAuth(*githubUser, *githubToken) } diff --git a/node/rpcstack_test.go b/node/rpcstack_test.go index db08bd40cb43..38f486e52a89 100644 --- a/node/rpcstack_test.go +++ b/node/rpcstack_test.go @@ -39,7 +39,7 @@ func TestNewWebsocketUpgradeHandler_websocket(t *testing.T) { // TestIsWebsocket tests if an incoming websocket upgrade request is handled properly. func TestIsWebsocket(t *testing.T) { - r, _ := http.NewRequest("GET", "/", nil) + r, _ := http.NewRequest(http.MethodGet, "/", nil) assert.False(t, isWebsocket(r)) r.Header.Set("upgrade", "websocket") diff --git a/p2p/simulations/http.go b/p2p/simulations/http.go index 84f3af61cd0c..f24695882be9 100644 --- a/p2p/simulations/http.go +++ b/p2p/simulations/http.go @@ -100,7 +100,7 @@ type SubscribeOpts struct { // nodes and connections and filtering message events func (c *Client) SubscribeNetwork(events chan *Event, opts SubscribeOpts) (event.Subscription, error) { url := fmt.Sprintf("%s/events?current=%t&filter=%s", c.URL, opts.Current, opts.Filter) - req, err := http.NewRequest("GET", url, nil) + req, err := http.NewRequest(http.MethodGet, url, nil) if err != nil { return nil, err } @@ -213,18 +213,18 @@ func (c *Client) RPCClient(ctx context.Context, nodeID string) (*rpc.Client, err // Get performs a HTTP GET request decoding the resulting JSON response // into "out" func (c *Client) Get(path string, out interface{}) error { - return c.Send("GET", path, nil, out) + return c.Send(http.MethodGet, path, nil, out) } // Post performs a HTTP POST request sending "in" as the JSON body and // decoding the resulting JSON response into "out" func (c *Client) Post(path string, in, out interface{}) error { - return c.Send("POST", path, in, out) + return c.Send(http.MethodPost, path, in, out) } // Delete performs a HTTP DELETE request func (c *Client) Delete(path string) error { - return c.Send("DELETE", path, nil, nil) + return c.Send(http.MethodDelete, path, nil, nil) } // Send performs a HTTP request, sending "in" as the JSON request body and diff --git a/rpc/http.go b/rpc/http.go index ee23c79a1a95..41c168d219bb 100644 --- a/rpc/http.go +++ b/rpc/http.go @@ -186,7 +186,7 @@ func (hc *httpConn) doRequest(ctx context.Context, msg interface{}) (io.ReadClos if err != nil { return nil, err } - req, err := http.NewRequestWithContext(ctx, "POST", hc.url, io.NopCloser(bytes.NewReader(body))) + req, err := http.NewRequestWithContext(ctx, http.MethodPost, hc.url, io.NopCloser(bytes.NewReader(body))) if err != nil { return nil, err }