aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/main.go b/main.go
index 1027abb..b7c6e49 100644
--- a/main.go
+++ b/main.go
@@ -12,6 +12,12 @@ import (
12 _ "github.com/lib/pq" 12 _ "github.com/lib/pq"
13) 13)
14 14
15var renderer *frontend.Renderer
16
17func index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
18 renderer.RenderPage("index", w, make(map[string]interface{}))
19}
20
15func main() { 21func main() {
16 config := LoadConfig() 22 config := LoadConfig()
17 db, err := sql.Open("postgres", config.DBConnectionString()) 23 db, err := sql.Open("postgres", config.DBConnectionString())
@@ -20,13 +26,19 @@ func main() {
20 } 26 }
21 log.Println("database connection established") 27 log.Println("database connection established")
22 28
23 frontend := frontend.New("views") 29 renderer = frontend.New("views")
24 charakterin := login.New(db) 30 charakterin := login.New(db)
25 charakterin.UseRenderer(frontend) 31 charakterin.UseRenderer(renderer)
26 32
27 router := httprouter.New() 33 router := httprouter.New()
28 router.HandlerFunc("GET", "/login", charakterin.DisplayLogin) 34 router.HandlerFunc("GET", "/login", charakterin.DisplayLogin)
29 router.HandlerFunc("POST", "/login", charakterin.Login) 35 router.HandlerFunc("POST", "/login", charakterin.Login)
36 router.GET("/", index)
37
38 fs := http.FileServer(http.Dir("assets"))
39 http.Handle("/assets/", http.StripPrefix("/assets/", fs))
40
41 http.Handle("/", router)
30 42
31 log.Fatal(http.ListenAndServe(":8080", router)) 43 log.Fatal(http.ListenAndServe(":8080", nil))
32} 44}