- Install the github.com/gorilla/mux package using the go get command, as follows:
$ go get github.com/gorilla/mux
- Create http-error-handling.go, where we will create a custom handler that acts as a wrapper to handle all the HTTP requests, as follows:
package mainimport ( "errors" "fmt" "log" "net/http" "strings" "github.com/gorilla/mux")const ( CONN_HOST = "localhost" CONN_PORT = "8080")type NameNotFoundError struct { Code int Err error}func (nameNotFoundError NameNotFoundError) Error() string { return nameNotFoundError.Err.Error()}type WrapperHandler func(http.ResponseWriter, *http.Request) errorfunc (wrapperHandler WrapperHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { err := wrapperHandler(w, r) if err != ...