From 8763022c77f0ad8edf6578962a524715d99e8d39 Mon Sep 17 00:00:00 2001 From: Horus3 Date: Tue, 24 Feb 2015 16:33:24 +0100 Subject: Session storage. Add new jobs over Webpage. Improved makefile. --- app/main.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'app/main.go') diff --git a/app/main.go b/app/main.go index 17d3157..b2c210c 100644 --- a/app/main.go +++ b/app/main.go @@ -3,26 +3,44 @@ package main import ( "github.com/gorilla/mux" "github.com/gorilla/schema" + "github.com/gorilla/sessions" "github.com/robfig/cron" "html/template" + "log" "net/http" "os" ) var decoder = schema.NewDecoder() +var store = sessions.NewCookieStore([]byte(RandomKey())) + var mainTempl = template.Must(template.New("global").ParseGlob("../views/*.html")) var c = cron.New() func main() { + decoder.IgnoreUnknownKeys(true) + store.Options = &sessions.Options{ + Path: "/", + MaxAge: 86400, + HttpOnly: true, + } checkConfig() jobRun() InitDB() insertHost() + insertAdmin() + go func() { + err := FillCache() + if err != nil { + log.Panic(err) + } + }() r := mux.NewRouter() r.HandleFunc("/", IndexHandler) + r.HandleFunc("/session", SessionHandler) r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir("./../static")))) r.HandleFunc("/register", RegisterHandler).Methods("POST") r.HandleFunc("/register", PrintRegisterHandler).Methods("GET") -- cgit v1.2.3