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 handler function for the products listing page

Let's examine the products.go source file found in the handlers directory:

package handlersimport (  "net/http"  "github.com/EngineerKamesh/igb/igweb/common"  "github.com/EngineerKamesh/igb/igweb/shared/templatedata"  "github.com/isomorphicgo/isokit")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})  })}

Here, we fetch the slice of products, featured on the Products page, by calling the GetProducts method on the Redis ...

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