From bc53e1a1ff13d63e8622602b081c53f26c759d67 Mon Sep 17 00:00:00 2001 From: Stephen McQuay Date: Thu, 21 Feb 2013 00:19:38 -0800 Subject: [PATCH] go fmt --- handlers.go | 16 +++++++++++----- template.go | 4 ++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/handlers.go b/handlers.go index 9f6aef7..f1305fd 100644 --- a/handlers.go +++ b/handlers.go @@ -5,13 +5,19 @@ import ( "net/http" ) -func homeHandler(c http.ResponseWriter, req *http.Request) { - log.Printf("%v\n", req.URL) - T("index.html").Execute(c, map[string]interface{}{}) +func homeHandler(w http.ResponseWriter, req *http.Request) { + session, _ := store.Get(req, "creds") + loggedIn := session.Values["logged in"] + if loggedIn == nil { + http.Redirect(w, req, "/login", http.StatusSeeOther) + } + T("index.html").Execute(w, map[string]interface{}{}) } -func loginHandler(c http.ResponseWriter, req *http.Request) { +func loginHandler(w http.ResponseWriter, req *http.Request) { pwAttempt := req.FormValue("passwd") + // if pw matches, set session.Values["logged in"], then redirect to "/" + // else come back here.. log.Printf("%v\n", pwAttempt) - T("login.html").Execute(c, map[string]interface{}{}) + T("login.html").Execute(w, map[string]interface{}{}) } diff --git a/template.go b/template.go index c18aa19..ccf70b4 100644 --- a/template.go +++ b/template.go @@ -20,6 +20,6 @@ func T(name string) *template.Template { "templates/_base.html", filepath.Join(*template_dir, name), )) - cachedTemplates[name] = t - return t + cachedTemplates[name] = t + return t }