- Install the github.com/gorilla/mux package, using the go get command, as follows:
$ go get github.com/gorilla/mux
- Create http-rest-versioning.go where we will define two versions of the same URL path that support the HTTP GET method, with one having v1 as a prefix and the other one with v2 as a prefix in the route, as follows:
package mainimport ( "encoding/json" "log" "net/http" "strings" "github.com/gorilla/mux")const ( CONN_HOST = "localhost" CONN_PORT = "8080")type Route struct { Name string Method string Pattern string HandlerFunc http.HandlerFunc}type Routes []Routevar routes = Routes{ Route { "getEmployees", "GET", "/employees", getEmployees, },}type Employee struct { Id string `json:"id"` FirstName string `json:"firstName"` ...