Shopping cart routes

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:

r.Handle("/shopping-cart", handlers.ShoppingCartHandler(env))

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)
  • Removing an item (/restapi/remove-item-from-cart)
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.220.83