-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.go
53 lines (44 loc) · 1.06 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
package main
import (
"domain0/config"
"domain0/database"
_ "domain0/docs"
"domain0/routers"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/swagger"
"github.com/sirupsen/logrus"
)
// @title Domain0 API
// @description Domain0 API
// @version 0.0.1
// @schemes http https
// @host localhost:8080
// @contact.name domain0
// @contact.email [email protected]
// @license.name MPL(mozilla public license)-2.0
// @license.url https://www.mozilla.org/en-US/MPL/2.0/
func main() {
// read config file
if err := config.Read("./config.yaml"); err != nil {
logrus.Error("Failed to read config file")
logrus.Fatal(err)
}
// init database
if err := database.Init(); err != nil {
logrus.Error("Failed to init database")
logrus.Fatal(err)
}
f := fiber.New(fiber.Config{
// set fiber config
})
// init swagger
f.Get("/swagger/*", swagger.HandlerDefault)
// init router
routers.InitRouter(f)
// add static resource
f.Static("/", "./static")
f.Use(func(c *fiber.Ctx) error {
return c.SendFile("./static/index.html")
})
f.Listen(config.CONFIG.BindAddr)
}