diff options
| author | Horus3 | 2015-02-24 16:33:24 +0100 |
|---|---|---|
| committer | Horus3 | 2015-02-24 16:33:24 +0100 |
| commit | 8763022c77f0ad8edf6578962a524715d99e8d39 (patch) | |
| tree | c5b2557c56ebad2929cd02951b719aeff68b73ba /app/main.go | |
| parent | 70d080b69a1bce3125d8d0b83e23775880241763 (diff) | |
| download | statuspage-8763022c77f0ad8edf6578962a524715d99e8d39.tar.gz | |
Session storage. Add new jobs over Webpage. Improved makefile.
Diffstat (limited to 'app/main.go')
| -rw-r--r-- | app/main.go | 18 |
1 files changed, 18 insertions, 0 deletions
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") |
