summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorhorus_arch2015-03-19 13:39:37 +0100
committerhorus_arch2015-03-19 13:39:37 +0100
commitf334c93c0364d14a2b55641b155ad58f715a4b39 (patch)
tree63ffbfc845f441802bd59c07adf2d9fe2f86c4bc /main.go
parent3c9bdbc66998075278f7d79fa10709e7fab5deb6 (diff)
downloadfreemail-f334c93c0364d14a2b55641b155ad58f715a4b39.tar.gz
Rewriting from scratch.
Diffstat (limited to 'main.go')
-rw-r--r--main.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..b18bd8d
--- /dev/null
+++ b/main.go
@@ -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")
+}