-
Notifications
You must be signed in to change notification settings - Fork 11
/
main.go
60 lines (49 loc) · 1.26 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
59
60
package main
import (
"multi-chain-storage/common/constants"
"multi-chain-storage/config"
"multi-chain-storage/database"
"multi-chain-storage/routers"
"multi-chain-storage/service/scheduler"
"os"
"strconv"
"time"
"github.com/filswan/go-swan-lib/logs"
"github.com/gin-gonic/gin"
cors "github.com/itsjamie/gin-cors"
)
func main() {
paymentChainName := constants.PAYMENT_CHAIN_NAME_POLYGON_MUMBAI
if len(os.Args) > 1 {
paymentChainName = os.Args[1]
}
config.InitConfig(paymentChainName)
db := database.Init()
defer database.CloseDB(db)
scheduler.InitScheduler()
createGinServer()
}
func createGinServer() {
if config.GetConfig().Release {
gin.SetMode(gin.ReleaseMode)
}
r := gin.Default()
r.Use(cors.Middleware(cors.Config{
Origins: "*",
Methods: "GET, PUT, POST, DELETE",
RequestHeaders: "Origin, Authorization, Content-Type",
ExposedHeaders: "",
MaxAge: 50 * time.Second,
Credentials: true,
ValidateHeaders: false,
}))
v1 := r.Group("/api/v1")
routers.HostManager(v1.Group("common"))
routers.BillingManager(v1.Group("billing"))
routers.Storage(v1.Group("storage"))
routers.Dao(v1.Group("dao"))
err := r.Run(":" + strconv.Itoa(config.GetConfig().Port))
if err != nil {
logs.GetLogger().Fatal(err)
}
}