go fmt
This commit is contained in:
parent
e2d1c76142
commit
bc53e1a1ff
16
handlers.go
16
handlers.go
@ -5,13 +5,19 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
func homeHandler(c http.ResponseWriter, req *http.Request) {
|
func homeHandler(w http.ResponseWriter, req *http.Request) {
|
||||||
log.Printf("%v\n", req.URL)
|
session, _ := store.Get(req, "creds")
|
||||||
T("index.html").Execute(c, map[string]interface{}{})
|
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")
|
pwAttempt := req.FormValue("passwd")
|
||||||
|
// if pw matches, set session.Values["logged in"], then redirect to "/"
|
||||||
|
// else come back here..
|
||||||
log.Printf("%v\n", pwAttempt)
|
log.Printf("%v\n", pwAttempt)
|
||||||
T("login.html").Execute(c, map[string]interface{}{})
|
T("login.html").Execute(w, map[string]interface{}{})
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,6 @@ func T(name string) *template.Template {
|
|||||||
"templates/_base.html",
|
"templates/_base.html",
|
||||||
filepath.Join(*template_dir, name),
|
filepath.Join(*template_dir, name),
|
||||||
))
|
))
|
||||||
cachedTemplates[name] = t
|
cachedTemplates[name] = t
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user