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 product detail page

Let's examine the ProductDetailHandler function defined in the productdetail.go source file found in the client/handlers directory:

func ProductDetailHandler(env *common.Env) isokit.Handler {  return isokit.HandlerFunc(func(ctx context.Context) {    routeVars := ctx.Value(isokit.RouteVarsKey("Vars")).(map[string]string)    productTitle := routeVars[`product-detail/{productTitle}`]    productChannel := make(chan *models.Product)    go FetchProductDetail(productChannel, productTitle)    product := <-productChannel    templateData := &templatedata.ProductDetail{PageTitle: product.Name, Product: product} env.TemplateSet.Render("product_detail_content", &isokit.RenderParams{Data: templateData, Disposition: isokit.PlacementReplaceInnerContents, ...

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