ways of doing HTTP requests

suggest change

Package net/http has a layered design where each layer is a convenience wrapper on top of a lower layer.

Each lower layer is more complex but offers more control.

Here’s a recap of 3 ways of doing an HTTP GET request.

Use http.Get() function

The top-level http.Get function is the simplest, but it is not recommended because http.DefaultClient has no timeout.

Use http.Client.Get() method

Use http.Client.Do() method

This allows the greatest control over the request.

net/http has no http.Put or http.Delete helper. Build the request and send it with Client.Do, or with http.DefaultClient.Do.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents