aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorJan C <jan@ruken.pw>2016-03-28 12:30:15 (UTC)
committerJan C <jan@ruken.pw>2016-03-28 12:30:15 (UTC)
commite8f2412efe55c969390168e3ce0b41200f780a1e (patch)
tree41a0e692d0ded0113394712f750b730c4f4fa864 /main.go
parentc7f28c0032163075bd21f899c37ae992e3eece80 (diff)
cache hinzugefuegt. wird derzeit vom lists und grils modul verwendet. versuch die loadingzeit zu verringern (anscheinend wird im hintergrund auf jeder route der index requested, was ziemlich doof ist).
Diffstat (limited to 'main.go')
-rw-r--r--main.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/main.go b/main.go
index 6311304..dd24d01 100644
--- a/main.go
+++ b/main.go
@@ -17,12 +17,17 @@ import (
17 17
18 "github.com/julienschmidt/httprouter" 18 "github.com/julienschmidt/httprouter"
19 _ "github.com/lib/pq" 19 _ "github.com/lib/pq"
20 "strings"
20) 21)
21 22
22var app *grilist.Grilist 23var app *grilist.Grilist
23 24
24func index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { 25func index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
25 http.Redirect(w, r, "/dashboard", 302) 26 if strings.Index(r.Referer(), "127.0.0.1") != -1 {
27 w.WriteHeader(200)
28 return
29 }
30 http.Redirect(w, r, "/dashboard", 301)
26} 31}
27 32
28func loadModule(mod grilist.Module) error { 33func loadModule(mod grilist.Module) error {
@@ -61,6 +66,7 @@ func main() {
61 router, 66 router,
62 } 67 }
63 68
69 router.GET("/", index)
64 router.HandlerFunc("GET", "/login", login.DisplayLogin) 70 router.HandlerFunc("GET", "/login", login.DisplayLogin)
65 router.HandlerFunc("POST", "/login", login.Login) 71 router.HandlerFunc("POST", "/login", login.Login)
66 router.HandlerFunc("GET", "/settings", login.DisplayUserSettings) 72 router.HandlerFunc("GET", "/settings", login.DisplayUserSettings)
@@ -68,8 +74,6 @@ func main() {
68 router.HandlerFunc("GET", "/logout", login.Logout) 74 router.HandlerFunc("GET", "/logout", login.Logout)
69 router.HandlerFunc("GET", "/register", login.DisplayRegistration) 75 router.HandlerFunc("GET", "/register", login.DisplayRegistration)
70 router.HandlerFunc("POST", "/register", login.Register) 76 router.HandlerFunc("POST", "/register", login.Register)
71 router.GET("/", index)
72 router.GET("/dashboard", viewDashboard)
73 77
74 fs := http.FileServer(http.Dir("assets")) 78 fs := http.FileServer(http.Dir("assets"))
75 http.Handle("/assets/", http.StripPrefix("/assets/", fs)) 79 http.Handle("/assets/", http.StripPrefix("/assets/", fs))
@@ -81,6 +85,7 @@ func main() {
81 loadModule(tags.New()) 85 loadModule(tags.New())
82 loadModule(search.New()) 86 loadModule(search.New())
83 loadModule(user.New()) 87 loadModule(user.New())
88 router.GET("/dashboard", viewDashboard)
84 89
85 log.Fatal(http.ListenAndServe(":8080", nil)) 90 log.Fatal(http.ListenAndServe(":8080", nil))
86} 91}