Skip to content

Commit d55dca0

Browse files
committed
all: use http package to replace http method names (26535)
1 parent 05a0f20 commit d55dca0

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

cmd/faucet/faucet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ func sendSuccess(conn *wsConn, msg string) error {
657657
func authGitHub(url string) (string, string, common.Address, error) {
658658
// Retrieve the gist from the GitHub Gist APIs
659659
parts := strings.Split(url, "/")
660-
req, _ := http.NewRequest("GET", "https://api.github.com/gists/"+parts[len(parts)-1], nil)
660+
req, _ := http.NewRequest(http.MethodGet, "https://api.github.com/gists/"+parts[len(parts)-1], nil)
661661
if *githubUser != "" {
662662
req.SetBasicAuth(*githubUser, *githubToken)
663663
}

node/rpcstack_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TestNewWebsocketUpgradeHandler_websocket(t *testing.T) {
3939

4040
// TestIsWebsocket tests if an incoming websocket upgrade request is handled properly.
4141
func TestIsWebsocket(t *testing.T) {
42-
r, _ := http.NewRequest("GET", "/", nil)
42+
r, _ := http.NewRequest(http.MethodGet, "/", nil)
4343

4444
assert.False(t, isWebsocket(r))
4545
r.Header.Set("upgrade", "websocket")

p2p/simulations/http.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ type SubscribeOpts struct {
100100
// nodes and connections and filtering message events
101101
func (c *Client) SubscribeNetwork(events chan *Event, opts SubscribeOpts) (event.Subscription, error) {
102102
url := fmt.Sprintf("%s/events?current=%t&filter=%s", c.URL, opts.Current, opts.Filter)
103-
req, err := http.NewRequest("GET", url, nil)
103+
req, err := http.NewRequest(http.MethodGet, url, nil)
104104
if err != nil {
105105
return nil, err
106106
}
@@ -213,18 +213,18 @@ func (c *Client) RPCClient(ctx context.Context, nodeID string) (*rpc.Client, err
213213
// Get performs a HTTP GET request decoding the resulting JSON response
214214
// into "out"
215215
func (c *Client) Get(path string, out interface{}) error {
216-
return c.Send("GET", path, nil, out)
216+
return c.Send(http.MethodGet, path, nil, out)
217217
}
218218

219219
// Post performs a HTTP POST request sending "in" as the JSON body and
220220
// decoding the resulting JSON response into "out"
221221
func (c *Client) Post(path string, in, out interface{}) error {
222-
return c.Send("POST", path, in, out)
222+
return c.Send(http.MethodPost, path, in, out)
223223
}
224224

225225
// Delete performs a HTTP DELETE request
226226
func (c *Client) Delete(path string) error {
227-
return c.Send("DELETE", path, nil, nil)
227+
return c.Send(http.MethodDelete, path, nil, nil)
228228
}
229229

230230
// Send performs a HTTP request, sending "in" as the JSON request body and

rpc/http.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func (hc *httpConn) doRequest(ctx context.Context, msg interface{}) (io.ReadClos
186186
if err != nil {
187187
return nil, err
188188
}
189-
req, err := http.NewRequestWithContext(ctx, "POST", hc.url, io.NopCloser(bytes.NewReader(body)))
189+
req, err := http.NewRequestWithContext(ctx, http.MethodPost, hc.url, io.NopCloser(bytes.NewReader(body)))
190190
if err != nil {
191191
return nil, err
192192
}

0 commit comments

Comments
 (0)