Whenever we have to send data to the server either through an asynchronous call or through an HTML form, then we go with the HTTP POST method implementation, which we will cover in this recipe.
Creating your first HTTP POST method
How to do it...
- Install the github.com/gorilla/mux package using the go get command, as follows:
$ go get github.com/gorilla/mux
- Create http-rest-post.go where we will define an additional route that supports the HTTP POST method and a handler that adds an employee to the initial static array of employees and writes the updated list to an HTTP response stream, as follows:
package main
import
(
"encoding/json"
"log"
"net/http"
"github.com/gorilla/mux"...