Essential Go HTTP Client edit forum

ways of doing HTTP requests

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

Using top-level http.Get() function is the simplest but not recommended due to lack of timeouts.

Use http.Client.Get() method

Use http.Client.Do() method

This allows the greatest control over the request.

This is the only way to do PUT or DELETE requests.

  ↑ ↓ to navigate     ↵ to select     Esc to close