In this recipe, we will use gorilla/mux to define a few routes, like we did in our previous recipe, along with their handlers or resources. As we have already seen in one of our previous recipes, to use external packages, first we have to install the package using the go get command or we have to copy it manually to $GOPATH/src or $GOPATH. We will do the same in the recipe as well. Perform the following steps:
- Install github.com/gorilla/mux using the go get command, as follows:
$ go get github.com/gorilla/mux
- Create http-server-gorilla-mux-routing.go and copy the following content:
package mainimport ( "net/http" "github.com/gorilla/mux")const ( CONN_HOST = "localhost" CONN_PORT = "8080")var GetRequestHandler = http.HandlerFunc ...