diff options
| author | horus_arch | 2015-03-19 13:39:37 +0100 |
|---|---|---|
| committer | horus_arch | 2015-03-19 13:39:37 +0100 |
| commit | f334c93c0364d14a2b55641b155ad58f715a4b39 (patch) | |
| tree | 63ffbfc845f441802bd59c07adf2d9fe2f86c4bc /main.go | |
| parent | 3c9bdbc66998075278f7d79fa10709e7fab5deb6 (diff) | |
| download | freemail-f334c93c0364d14a2b55641b155ad58f715a4b39.tar.gz | |
Rewriting from scratch.
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 49 |
1 files changed, 49 insertions, 0 deletions
@@ -0,0 +1,49 @@ +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 store = sessions.NewCookieStore([]byte(os.Getenv("FREEMAIL_SECRET"))) + +var mainTempl = template.Must(template.New("global").Funcs(template.FuncMap{"add": add}).ParseGlob("./views/*.html")) +var emailTempl = template.Must(template.New("email").Funcs(template.FuncMap{"add": add}).ParseGlob("./views/email/*.html")) + +var c = cron.New() + +func add(x, y int) int { + return x + y +} + +func main() { + decoder.IgnoreUnknownKeys(true) + store.Options = &sessions.Options{ + Path: "/", + MaxAge: 86400, + HttpOnly: true, + } + checkConfig() + InitDB() + + r := mux.NewRouter() + // r.HandleFunc("/", IndexHandler) + r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir("./../static")))) + + http.Handle("/", r) + + ip := os.Getenv("FREEMAIL_HTTP_IP") + port := os.Getenv("FREEMAIL_HTTP_PORT") + + http.ListenAndServe(ip+":"+port, nil) + log.Println("Ales oke") +} |
