Whenever we want to remove a record that is no longer required then we go with the HTTP DELETE method implementation, which we will cover in this recipe.
Creating your first HTTP DELETE 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-delete.go where we will define a route that supports the HTTP DELETE method and a handler that deletes the employee details for the provided ID from the static array of employees, marshals the array to JSON, and writes it to an HTTP response stream, as follows:
package main
import
(
"encoding/json"
"log"
"net/http"
"github.com/gorilla/mux"
)
const...