package main import ( "fmt" "html" "log" "net/http" ) func (this *Application) Templatepage(w http.ResponseWriter, r *http.Request, pageDesc, extraHead string, cb func()) { pageTitle := this.cfg.Template.AppName if pageDesc != "" { pageTitle = pageDesc + ` | ` + pageTitle } w.Header().Set(`Content-Type`, `text/html; charset=UTF-8`) w.WriteHeader(200) fmt.Fprint(w, ` `+html.EscapeString(pageTitle)+` `+extraHead+`

`+html.EscapeString(this.cfg.Template.AppName)+`

`) cb() fmt.Fprint(w, ` `) } func (this *Application) internalError(w http.ResponseWriter, r *http.Request, err error) { log.Printf("%s %s: %s", r.Method, r.URL.Path, err) http.Error(w, "An internal error occurred.", 500) } func (this *Application) Delay(w http.ResponseWriter, r *http.Request) { this.Templatepage(w, r, "Loading...", "", func() { fmt.Fprintf(w, `

Loading, please wait...

`) }) }