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

The server-side shopping cart handler function

The ShoppingCartHandler function, defined in handlers/shoppingcart.go, is responsible for servicing the /shopping-cart route:

func ShoppingCartHandler(env *common.Env) http.Handler {  return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

The main purpose of the server-side shopping cart handler function is to produce the output for the shopping cart web page.

Recall that the handler functions for the product-related pages, tapped into the Redis datastore to retrieve the list of products. The shopping cart handler, on the other hand, taps into the server-side session to get the list of items that are in the shopping cart.

We will declare the variables for the templateData object ...

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