-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
40 lines (31 loc) · 984 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
package main
import (
"flag"
"fmt"
"log"
"net/http"
"os"
"github.com/gorilla/handlers"
"github.com/gnotclub/albumify-next/controllers"
"github.com/gnotclub/albumify-next/util"
)
func main() {
util.GetLogger()
// Get config file path from command line args
var configFile = flag.String("config", "config.json", "path of the config file")
flag.Parse()
util.ReadConfig(*configFile)
util.GetDBSession()
defer util.DBSession.Close()
util.GetRouter()
// Register routes for all of Album's controllers
controllers.AlbumRegisterController()
// Register main client's controllers
controllers.CompileClientTemplates()
controllers.ClientRegisterController()
// Listen
address := fmt.Sprintf("%s:%d", util.Config.ServerHostname, util.Config.ServerPort)
util.Logger.Printf("Listening on %s", address)
http.Handle("/", &util.MyServer{util.MainRouter})
log.Fatal(http.ListenAndServe(address, handlers.LoggingHandler(os.Stdout, &util.MyServer{util.MainRouter})))
}