summaryrefslogtreecommitdiff
path: root/handler.go
diff options
context:
space:
mode:
Diffstat (limited to 'handler.go')
-rw-r--r--handler.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/handler.go b/handler.go
index 0dc2033..9d4bcdf 100644
--- a/handler.go
+++ b/handler.go
@@ -43,6 +43,11 @@ func userFromSess(sess *sessions.Session) model.User {
return user
}
+type tpldata struct {
+ Mail string
+ Data interface{}
+}
+
func mkHttpHandler(h Handler, tpl *template.Template) http.HandlerFunc {
return func(rw http.ResponseWriter, req *http.Request) {
sess, err := getSess(req)
@@ -53,12 +58,16 @@ func mkHttpHandler(h Handler, tpl *template.Template) http.HandlerFunc {
user := userFromSess(sess)
outdata := h(user, sess, req)
+ mail := ""
+ if user != nil {
+ mail = user.Email()
+ }
if err := sess.Save(req, rw); err != nil {
log.Printf("Error while saving session: %s", err)
}
- if err := tpl.Execute(rw, outdata); err != nil {
+ if err := tpl.Execute(rw, &tpldata{mail, outdata}); err != nil {
log.Printf("Error executing template %s: %s", tpl.Name(), err)
}
}