How to do it...

  1. Install the github.com/gorilla/mux and gopkg.in/resty.v1 packages using the go get command, as follows:
$ go get github.com/gorilla/mux$ go get -u gopkg.in/resty.v1
  1. Create http-rest-client.go where we will define handlers that call resty handlers, such as GET, POST, PUT, and DELETE, get the response from the REST service, and write it to an HTTP response stream, as follows:
package mainimport (  "encoding/json"  "fmt"  "log"  "net/http"  "github.com/gorilla/mux"  resty "gopkg.in/resty.v1")const (  CONN_HOST = "localhost"  CONN_PORT = "8090")const WEB_SERVICE_HOST string = "http://localhost:8080"type Employee struct {  Id string `json:"id"`  FirstName string `json:"firstName"`  LastName string `json:"lastName"`}func getEmployees(w ...

Get Go Web Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.