Implementing the e-commerce REST API

Before jumping in, let us design the API specification table, which shows the REST API signatures for various URL endpoints. Refer to the following table:

Endpoint Method Description
/v1/user/id GET Get a user using ID
/v1/user POST Create a new user
/v1/user?first_name=NAME GET Get all users by the given first name
/v1/order/id GET Get an order with the given ID
/v1/order POST Create a new order

Now we come to the main program; let us add one more file to our jsonstore project. In this program, we will try to implement the first three endpoints. We suggest the implementation of the remaining two endpoints as an assignment for the reader. Take a look at the following command:

touch jsonstore/main.go ...

Get Building RESTful Web services with Go 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.