package view import ( "html/template" "net/http" "streifling.com/jason/cpolis/cmd/control" "streifling.com/jason/cpolis/cmd/model" ) func CreateTag(c *control.Config) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { tmpl, err := template.ParseFiles(c.WebDir + "/templates/add-tag.html") template.Must(tmpl, err).ExecuteTemplate(w, "page-content", nil) } } func AddTag(c *control.Config, db *model.DB, s *control.CookieStore) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { db.AddTag(r.PostFormValue("tag")) session, err := s.Get(r, "cookie") if err != nil { tmpl, err := template.ParseFiles(c.WebDir + "/templates/login.html") msg := "Session nicht mehr gültig. Bitte erneut anmelden." template.Must(tmpl, err).ExecuteTemplate(w, "page-content", msg) } tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html") tmpl = template.Must(tmpl, err) tmpl.ExecuteTemplate(w, "page-content", session.Values["role"]) } }