Esempio n. 1
0
func tpl_error(w http.ResponseWriter, r *http.Request) {
	var page struct {
		Nonsense string
	}
	out, err := webshell.ServeTemplateFile("templates/test.html", page)
	if err != nil {
		fmt.Println("[!] error")
		webshell.Error500(err.Error(), "text/plain", w, r)
	} else {
		w.Write(out)
	}
}
Esempio n. 2
0
func tpl_test2(w http.ResponseWriter, r *http.Request) {
	var page struct {
		Title     string
		Paragraph string
	}
	page.Title = "another test page"
	page.Paragraph = "Sæmundar Edda"
	out, err := webshell.ServeTemplateFile("templates/test.html", page)
	if err != nil {
		webshell.Error500(err.Error(), "text/plain", w, r)
	} else {
		w.Write(out)
	}
}