summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorHorus_Arch2015-02-24 18:58:08 +0100
committerHorus_Arch2015-02-24 18:58:08 +0100
commit9e1d8d0fb2b57903b1c6c0c2765b7808655c74a0 (patch)
treea3f8546269eec6edb84fa740bc485c37542498bc /app
parent8763022c77f0ad8edf6578962a524715d99e8d39 (diff)
downloadstatuspage-9e1d8d0fb2b57903b1c6c0c2765b7808655c74a0.tar.gz
Struct with flash and error messages to differentiate in template.
Diffstat (limited to 'app')
-rw-r--r--app/handler.go21
-rw-r--r--app/struct.go5
2 files changed, 12 insertions, 14 deletions
diff --git a/app/handler.go b/app/handler.go
index 7dd8cc4..3f30c9f 100644
--- a/app/handler.go
+++ b/app/handler.go
@@ -57,24 +57,17 @@ func PrintRegisterHandler(w http.ResponseWriter, r *http.Request) {
func PrintNewJobHandler(w http.ResponseWriter, r *http.Request) {
log.Println("Printing job")
- var t string
session, err := store.Get(r, "_SID")
- flashes := session.Flashes("success")
- if len(flashes) > 0 {
- t = "jobs.html"
- } else {
- flashes = session.Flashes("error")
- t = "jobs_error.html"
- }
+
+ m := FlashMessages{}
+ m.Success = session.Flashes("success")
+ m.Error = session.Flashes("error")
session.Save(r, w)
- job := mainTempl.Lookup(t)
- //flashes := session.Flashes()
- //flashes := session.Flashes("success")
- //flashes := session.Flashes("error")
- fmt.Println(flashes)
- err = job.ExecuteTemplate(w, t, flashes)
+ job := mainTempl.Lookup("jobs.html")
+
+ err = job.ExecuteTemplate(w, "jobs.html", m)
if err != nil {
log.Panic(err)
}
diff --git a/app/struct.go b/app/struct.go
index 37704d7..73e1dc7 100644
--- a/app/struct.go
+++ b/app/struct.go
@@ -36,3 +36,8 @@ type User struct {
DeletedAt time.Time
UpdatedAt time.Time
}
+
+type FlashMessages struct {
+ Success []interface{}
+ Error []interface{}
+}