/
main.go
47 lines (36 loc) · 936 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
package main
import (
"os"
"github.com/kylechadha/omnia-app/app"
"github.com/kylechadha/omnia-app/controllers"
"github.com/kylechadha/omnia-app/routes"
"github.com/kylechadha/omnia-app/services"
"github.com/codegangsta/negroni"
)
func main() {
// Config
// ----------------------------
// Set the port.
port := os.Getenv("PORT")
if port == "" {
port = "3000"
}
// Object Graph
// ----------------------------
app := app.Ioc{}
app.ConfigService = services.NewConfigService()
app.DatabaseService = services.NewDatabaseService(&app)
app.DaysController = controllers.NewDaysController(&app)
// Router
// ----------------------------
router := routes.NewRouter(&app)
// Do we want to use negroni again? Meh ... what about another way to do recovery
n := negroni.New(
negroni.NewRecovery(),
negroni.NewLogger(),
)
n.UseHandler(router)
// Server
// ----------------------------
n.Run(":" + port)
}