Example #1
0
// 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)
	}
}
Example #2
0
// 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)
	}
}