By implementing the ShoppingCart type, we now have the business logic in place, to drive the shopping cart functionality. Now it's time to register the server-side routes that are needed to implement the shopping cart.
We register the /shopping-cart route along with its associated handler function, ShoppingCartHandler, inside the registerRoutes function, which is found in the igweb.go source file:
The route handler function, ShoppingCartHandler, is responsible for generating the web page for the shopping cart page on the server side.
We also register the following Rest API endpoints:
- Fetching a list of items (/restapi/get-cart-items)
- Adding an item (/restapi/add-item-to-cart ...