-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
49 lines (38 loc) · 920 Bytes
/
main.go
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"net/http"
"os"
rice "github.com/GeertJohan/go.rice"
"github.com/gorilla/mux"
log "github.com/sirupsen/logrus"
)
var configPath = "config.toml"
var conf Config
var router *mux.Router
var templateBox *rice.Box
func main() {
if len(os.Args) >= 2 {
configPath = os.Args[1]
}
// load config
var err error
conf, err = ParseConfig(configPath)
if err != nil {
log.Fatal(err)
}
log.SetLevel(conf.Server.LogLevel)
// find template box
log.Infoln("Finding box templates")
templateBox, err = rice.FindBox("templates")
if err != nil {
log.Fatal(err)
}
// setup router
router = mux.NewRouter()
router.HandleFunc("/", indexHandler)
router.HandleFunc("/profiles/{profile}", profileHandler).Name("profile")
router.HandleFunc("/profiles/{profile}/view", profileViewHandler)
// listen and serve
address := conf.Server.Addr
log.Fatal(http.ListenAndServe(address, router))
}