How to do it...

  1. Create a reactjs-client directory where we will keep all our ReactJS source files and an HTTP server, as follows:
$ mkdir reactjs-client && cd reactjs-client && touch server.go
  1. Copy the following code to server.go:
package mainimport (  "encoding/json"  "log"  "net/http"  "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,  },  Route  {    "addEmployee",    "POST",    "/employee/add",    addEmployee,  },}type Employee struct {  Id string `json:"id"`  FirstName string `json:"firstName"`  LastName string `json:"lastName"`}type Employees ...

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.