-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
52 lines (41 loc) · 1.12 KB
/
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
50
51
52
package main
//go:generate statik -src=.\static
//go generate go get github.com/jteeuwen/go-bindata/...
//go:generate go-bindata -o settings.go -pkg main settings/...
import (
"encoding/json"
"os"
"github.com/enlivengo/admin"
"github.com/enlivengo/database"
"github.com/enlivengo/enliven"
"github.com/enlivengo/enliven/config"
"github.com/enlivengo/enliven/middleware/session"
_ "github.com/enlivengo/skeleton/statik"
"github.com/enlivengo/static"
"github.com/enlivengo/statik"
"github.com/enlivengo/user"
)
func getConfig() config.Config {
environment := "development"
args := os.Args[1:]
if len(args) > 0 {
environment = args[0]
}
settingsBytes := MustAsset("settings/" + environment + ".json")
var enlivenConfig config.Config
if err := json.Unmarshal(settingsBytes, &enlivenConfig); err != nil {
panic(err)
}
return enlivenConfig
}
func main() {
ev := enliven.New(getConfig())
ev.AddMiddleware(session.NewMemoryStorageMiddleware())
ev.AddApp(static.NewApp())
ev.AddApp(statik.NewApp())
ev.AddApp(database.NewApp())
ev.AddApp(user.NewApp())
ev.AddApp(admin.NewApp())
ev.AddRoute("/", rootView)
ev.Run()
}