Sending data to a server
In addition to requesting data from a server, you will also want to send data to a server. The most common way of doing this is via a POST request. A POST request comes in two main parts: the URL and the body. The body of a POST request is where you put the data you want to send to the server. A common example of this is a login form. When we send a login request, we POST the body to the URL. The web server then checks that the login details within the body are correct and updates our login status. It responds to the request by telling the client whether it succeeded or not. In this section, you will learn how to send data to a server using a POST request.
Exercise 17.03 – sending a POST request to a web server using the Go HTTP Client
In this exercise, you will send a POST request to a web server containing a message. The web server will then respond with the same message so you can confirm that it received it:
- Create a new directory,...