diff --git a/handlers.go b/handlers.go index 4d0ebfe..d4bc6ce 100644 --- a/handlers.go +++ b/handlers.go @@ -24,3 +24,11 @@ func loginHandler(w http.ResponseWriter, req *http.Request) { } T("login.html").Execute(w, map[string]interface{}{}) } + +func logoutHandler(w http.ResponseWriter, req *http.Request) { + session, _ := store.Get(req, "creds") + delete(session.Values, "logged in") + session.Save(req, w) + http.Redirect(w, req, "/", http.StatusSeeOther) + return +} diff --git a/main.go b/main.go index 199b49b..b709d4f 100644 --- a/main.go +++ b/main.go @@ -29,6 +29,7 @@ func main() { } else { http.HandleFunc("/", homeHandler) http.HandleFunc("/login", loginHandler) + http.HandleFunc("/logout", logoutHandler) http.Handle("/s/", http.StripPrefix("/s/", http.FileServer(http.Dir(*static_files)))) if err := http.ListenAndServe(*addr, nil); err != nil {