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

Implementing isomorphic handoff for the products listing page

First, we must implement the Encode step. To do this, we need to decide the data that must be persisted to the client side. We can easily identify the data that must be persisted to the client, by examining the server side handler function, ProductsHandler, responsible for rendering the products listing web page:

func ProductsHandler(env *common.Env) http.Handler {  return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {    products := env.DB.GetProducts()    templateData := &templatedata.Products{PageTitle: "Products", Products: products}    env.TemplateSet.Render("products_page", &isokit.RenderParams{Writer: w, Data: templateData})  })}

The products listing page is responsible ...

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