forked from filswan/go-swan-provider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
51 lines (44 loc) · 1.03 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
package main
import (
"github.com/gin-gonic/gin"
cors "github.com/itsjamie/gin-cors"
"github.com/joho/godotenv"
"os"
"swan-miner/common/constants"
"swan-miner/config"
"swan-miner/logs"
"swan-miner/offlineDealAdmin"
"swan-miner/routers/commonRouters"
"time"
)
func main() {
//LoadEnv()
//config.InitConfig()
offlineDealAdmin.AdminOfflineDeal()
createHttpServer()
}
func createHttpServer() {
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")
commonRouters.HostManager(v1.Group(constants.URL_HOST_GET_COMMON))
err := r.Run(":" + config.GetConfig().Port)
if err != nil {
logs.GetLogger().Fatal(err)
}
}
func LoadEnv() {
err := godotenv.Load(".env")
if err != nil {
logs.GetLogger().Error(err)
}
logs.GetLogger().Info("name: ", os.Getenv("privateKey"))
}