-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
30 lines (25 loc) · 671 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
package main
import (
"log"
"net/http"
"github.com/benspotatoes/extrawatch/api"
"github.com/benspotatoes/extrawatch/backend"
"github.com/benspotatoes/extrawatch/config"
"goji.io"
)
func main() {
conf := config.NewConfig()
backendConf := &backend.Config{
ConnectOpts: conf.Db,
}
backend, err := backend.NewBackend(backendConf)
if err != nil {
log.Fatalf("unable to initialize backend: %s\n", err.Error())
}
mux := api.NewRouter(backend, &api.Config{Cors: conf.Cors})
serve(conf, mux)
}
func serve(conf *config.Extrawatch, mux *goji.Mux) {
log.Printf("serving application at %s", conf.HostPort)
log.Fatal(http.ListenAndServe(conf.HostPort, mux))
}