Request and Response objects
The request and response objects are the core of the http package. They can represent all the data you can generate in a request and all the data you can receive in a response. Not only that but the http package provides you with functionality for building HTTP clients and servers, and http.Request and http.Response provide that functionality to both sides. So, let’s explore them.
The request object
We typically create the request object with the http.NewRequest function. This function provides the basic Request object creation with the minimum data it needs, the method, the URL, and the body. Here is an example of how to create a request object:
request, err := http.NewRequest("GET", "https://example.com", nil)
It is simple, right? However, the request object has a lot of methods that allow you to configure every piece of it, such as setting the headers or changing the cookies. I don’t want to get into...