-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
50 lines (40 loc) · 859 Bytes
/
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
package main
import (
"auction/utils"
"time"
"auction/config"
database "auction/db"
"auction/logs"
common "auction/routers/comm"
"github.com/gin-gonic/gin"
cors "github.com/itsjamie/gin-cors"
)
func main() {
// init database
db := database.Init()
config.InitConfig("")
defer func() {
err := db.Close()
if err != nil {
logs.GetLogger().Error(err)
}
}()
// start timer
utils.Timer()
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,
}))
v := r.Group("/api/v1")
common.HostManager(v)
err := r.Run(":" + config.GetConfig().Port)
if err != nil {
logs.GetLogger().Fatal(err)
}
}