/
main.go
58 lines (43 loc) · 1.24 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
53
54
55
56
57
58
package main
import (
"log"
"github.com/elanticrypt0/gasonline/api/routes"
"github.com/elanticrypt0/gasonline/pkg/webcore"
"github.com/elanticrypt0/gasonline/pkg/webcore_features"
"github.com/elanticrypt0/go4it"
"github.com/gofiber/fiber/v2"
)
func main() {
app_config := go4it.NewApp("./config/appconfig")
gas := webcore.GasonlineApp{
App: &app_config,
Fiber: fiber.New(fiber.Config{
Prefork: false,
CaseSensitive: true,
StrictRouting: true,
ServerHeader: "Fiber",
AppName: app_config.Config.App_name,
DisableStartupMessage: false,
PassLocalsToViews: true,
}),
}
gas.PrintAppInfo()
// make the connection
app_config.Connect2Db("local")
app_config.DB.SetPrimaryDB(0)
// middleware
webcore.MiddlewareSetup(&gas)
// Routes setup
// webcore setup routes
if gas.App.Config.App_setup_enabled {
webcore_features.SetupRoutes(&gas)
webcore_features.SetupOnStartup(&gas)
}
// features routes
routes.SetupApiRoutes(&gas)
// static routes
webcore.SetupStaticRoutes(gas.Fiber)
portAsStr := gas.GetPortAsStr()
// go4it.OpenInBrowser("http://" + gas.GetAppUrl())
log.Fatal(gas.Fiber.Listen(gas.GetAppUrl()), "Server is running on port "+portAsStr)
}