aboutsummaryrefslogtreecommitdiff
path: root/main.go
blob: 1027abb87560371cd1c007704e123a8e71e11954 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main

import (
	"database/sql"
	"log"
	"net/http"

	login "fagott.pw/charakterin"
	"fagott.pw/grilist/frontend"

	"github.com/julienschmidt/httprouter"
	_ "github.com/lib/pq"
)

func main() {
	config := LoadConfig()
	db, err := sql.Open("postgres", config.DBConnectionString())
	if err != nil {
		log.Fatal(err)
	}
	log.Println("database connection established")

	frontend := frontend.New("views")
	charakterin := login.New(db)
	charakterin.UseRenderer(frontend)

	router := httprouter.New()
	router.HandlerFunc("GET", "/login", charakterin.DisplayLogin)
	router.HandlerFunc("POST", "/login", charakterin.Login)

	log.Fatal(http.ListenAndServe(":8080", router))
}