linx-server/pages.go

35 lines
866 B
Go
Raw Normal View History

2015-09-24 07:44:49 +02:00
package main
import (
"net/http"
2015-09-24 08:08:44 +02:00
"github.com/flosch/pongo2"
2015-09-24 07:44:49 +02:00
"github.com/zenazn/goji/web"
)
var indexTpl = pongo2.Must(pongo2.FromCache("templates/index.html"))
var notFoundTpl = pongo2.Must(pongo2.FromCache("templates/404.html"))
var oopsTpl = pongo2.Must(pongo2.FromCache("templates/oops.html"))
2015-09-24 07:44:49 +02:00
func indexHandler(c web.C, w http.ResponseWriter, r *http.Request) {
err := indexTpl.ExecuteWriter(pongo2.Context{}, w)
2015-09-24 07:44:49 +02:00
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
}
func notFoundHandler(c web.C, w http.ResponseWriter, r *http.Request) {
w.WriteHeader(404)
err := notFoundTpl.ExecuteWriter(pongo2.Context{}, w)
if err != nil {
oopsHandler(c, w, r)
}
}
func oopsHandler(c web.C, w http.ResponseWriter, r *http.Request) {
err := oopsTpl.ExecuteWriter(pongo2.Context{}, w)
if err != nil {
oopsHandler(c, w, r)
}
}