Пример #1
0
// Http handler for edit template
func editHandler(w http.ResponseWriter, r *http.Request, title string) {
	p, err := page.Load(title)
	if err != nil {
		p = &page.Structure{Title: title}
	}
	renderTemplate(w, "edit", p)
}
Пример #2
0
// Http handler for view template
func viewHandler(w http.ResponseWriter, r *http.Request, title string) {
	p, err := page.Load(title)
	if err != nil {
		http.Redirect(w, r, "/edit/"+title, http.StatusFound)
		return
	}
	renderTemplate(w, "view", p)
}