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 chapter, you will learn how to send data to a server using a POST request.
Exercise 14.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,
Exercise14...