O'Reilly logo

Isomorphic Go by Kamesh Balasubramanian

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required