go fmt
This commit is contained in:
parent
e2d1c76142
commit
bc53e1a1ff
16
handlers.go
16
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{}{})
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user