package main import ( "html/template" "log" "net/http" "meutel.net/meutel/go-examples/photoblog/admin" "github.com/gorilla/sessions" ) type PhotoBlog struct { *admin.AuthCookie Templates *template.Template } func (app *PhotoBlog) HomePage(res http.ResponseWriter, req *http.Request) { app.Templates.ExecuteTemplate(res, "home.html", app.CurrentSession(res, req).Values) } func main() { tpl, err := template.ParseGlob("templates/*.html") if err != nil { log.Fatalln(err) } admin := admin.AuthCookie{ Templates: tpl, Store: sessions.NewCookieStore([]byte("flQ6QzM/c3Jtdl9ycDx6OXRIfFgK")), } app := PhotoBlog{ AuthCookie: &admin, Templates: tpl, } http.HandleFunc("/", app.HomePage) http.HandleFunc("/login", app.LoginPage) http.HandleFunc("/logout", app.LogoutPage) http.ListenAndServeTLS(":9443", "../cert.pem", "../key.pem", nil) }