Implementing the logistics REST API

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

Endpoint Method Description
/v1/shipment/id GET Get a shipment from ID
/v1/package/id GET Get a package from ID
/v1/package?weight=n GET Get a package with a given weight in grams
/v1/shipment POST Create a new shipment
/v1/package POST Create a new package

To implement the preceding API, we need a main program that registers API routes to handler functions. Add one more file to our jsonstore project, like this:

touch jsonstore/main.go

In this program, we will try to implement the POST and GET endpoints for Package. We suggest implementing ...

Get Hands-On RESTful Web Services with Go - Second Edition 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.