// Retrieve the context value and render the chained handlers context page. func renderContextPage(w handlers.GhostWriter, r *http.Request) { err := templates.Render("templates/amber/context.amber", w, &struct{ Val string }{w.Context()[contextPageKey].(string)}) if err != nil { panic(err) } }
// Handle the session page requests. func sessionPageRenderer(w handlers.GhostWriter, r *http.Request) { var ( txt interface{} data sessionPageInfo title string ) ssn := w.Session() if r.Method == "GET" { txt = ssn.Data[sessionPageKey] } else { txt = r.FormValue(sessionPageKey) ssn.Data[sessionPageKey] = txt } if r.URL.Path == "/session/auth" { title = sessionPageAuthTitle } else { title = sessionPageTitle } if txt != nil { data = sessionPageInfo{ssn.ID(), title, txt.(string)} } else { data = sessionPageInfo{ssn.ID(), title, "[nil]"} } err := templates.Render("templates/session.tmpl", w, data) if err != nil { panic(err) } }
// Prepare the context value for the chained handlers context page. func setContext(w handlers.GhostWriter, r *http.Request) { w.Context()[contextPageKey] = time.Now().String() }