Exemplo n.º 1
0
func servePage(page *Page, w http.ResponseWriter, r *http.Request) {
	page.getPageCount()
	page.getAllViews()
	out, err := webshell.BuildTemplateFile(page.File, page)
	if err != nil {
		webshell.Error404(err.Error(), "text/plain", w, r)
	} else {
		w.Write(out)
	}
	LogRequest(page, r)
}
Exemplo n.º 2
0
func tpl_error(w http.ResponseWriter, r *http.Request) {
	var page struct {
		Nonsense string
	}
	out, err := webshell.BuildTemplateFile("templates/test.html", page)
	if err != nil {
		fmt.Println("[!] error")
		webshell.Error500(err.Error(), "text/plain", w, r)
	} else {
		w.Write(out)
	}
}
Exemplo n.º 3
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.BuildTemplateFile("templates/test.html", page)
	if err != nil {
		webshell.Error500(err.Error(), "text/plain", w, r)
	} else {
		w.Write(out)
	}
}