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 ...