-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaether.go
More file actions
60 lines (47 loc) · 1.12 KB
/
aether.go
File metadata and controls
60 lines (47 loc) · 1.12 KB
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
53
54
55
56
57
58
59
60
package AetherGo
import (
"AetherGo/internal/app"
"AetherGo/internal/config"
"AetherGo/internal/db"
"AetherGo/internal/log"
)
type App = app.App
func Bootstrap(appName string, models []interface{}, routeRegistrar func(*App), overrides ...config.Config) *App {
cfg := configure(overrides...)
app := app.NewApp(cfg)
db.ConnectDB(appName)
log.Infof("AetherGo version 1.0, using environment '%s'", appName)
routeRegistrar(app)
db.AutoMigrate(models...)
return app
}
func configure(overrides ...config.Config) *config.Config {
cfg := &config.Config{
Port: "8000",
Env: "development",
TemplatesDir: "templates",
StaticDir: "static",
}
if len(overrides) > 0 {
override := overrides[0]
if override.Port != "" {
cfg.Port = override.Port
}
if override.Env != "" {
cfg.Env = override.Env
}
if override.TemplatesDir != "" {
cfg.TemplatesDir = override.TemplatesDir
}
if override.StaticDir != "" {
cfg.StaticDir = override.StaticDir
}
}
return cfg
}
func RegisterRoutes(app *app.App, registerFunc func(*app.App)) {
registerFunc(app)
}
func Run(app *app.App) {
app.Run()
}