Example #1
0
func (d DynHandle) Render(w *bytes.Buffer, r *http.Request) {

	if err := d.gh(w, r); err != nil {
		log.Debug("[err] [%s]", d.dbg)

		switch err.Error() {
		case "NotFound":
			log.Warning("[ServeHTTP] [NotFound]")

			//w.Header().Set("Content-Type", "text/plain; charset=utf-8")
			w.WriteHeader(http.StatusNotFound)
			fmt.Fprintln(&error_page, "404 page not found")

			WriteErrorPageEnd(&error_page)
			fmt.Fprintln(w, &error_page)

		default:
			log.Warning("[ServeHTTP] [start]\n" + page.String())
			log.Warning("[ServeHTTP] [end]")

			//w.Header().Set("Content-Type", "text/plain; charset=utf-8")
			w.WriteHeader(http.StatusInternalServerError)
			fmt.Fprintln(&error_page, err.Error())

			WriteErrorPageEnd(&error_page)
			fmt.Fprintln(w, &error_page)
		}
	}
}