O'Reilly logo

Distributed Computing with Go by V.N. Nikhil Anurag

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Design decisions

We have defined our REST API and next we would like to implement the server. It is important to formulate what we want our server to accomplish before writing any code. The following are some of the specifications for the server:

  • We need to extract <id> for PUT, DELETE, and single resource GET Requests.
  • We want to log every incoming request similar to the helloWorldHandler.
  • It would be tedious and bad coding practice to duplicate so much effort. We can make use of closures and function literals to create new functions for us that will combine the tasks from previous two points.
  • In order to keep the example simple, we shall be using a map[string]bookResource to store the state of all book resources. All operations will be ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required