- Install the github.com/gorilla/mux and github.com/gorilla/handlers packages using the go get command, as follows:
$ go get github.com/gorilla/mux$ go get github.com/gorilla/handlers
- Create http-rest-api.go, where we will define three routes—/status, /get-token and /employees—along with their handlers, as follows:
package mainimport ( "encoding/json" "log" "net/http" "os" "github.com/gorilla/handlers" "github.com/gorilla/mux")const ( CONN_HOST = "localhost" CONN_PORT = "8080")type Employee struct { Id int `json:"id"` FirstName string `json:"firstName"` LastName string `json:"lastName"`}type Employees []Employeevar employees []Employeefunc init() { employees = Employees { Employee{Id: 1, FirstName: "Foo", LastName: "Bar"}, ...