added logout
This commit is contained in:
parent
2fee9546f8
commit
a8ff26af15
@ -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
|
||||
}
|
||||
|
1
main.go
1
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user