summaryrefslogtreecommitdiff
path: root/app/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'app/main.go')
-rw-r--r--app/main.go18
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")