main.go
1.47 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
package main
import (
"apigame/common/svconfig"
"apigame/common/svconst"
"apigame/common/svdto"
"apigame/common/svlog"
"apigame/common/svmysql"
"apigame/common/svredis"
"apigame/configs"
_ "apigame/routers"
"apigame/service/cardholder"
"github.com/astaxie/beego"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/plugins/cors"
)
func main() {
logs.Info("apigame")
//解决跨域问题
beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
AllowAllOrigins: true,
//AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
AllowMethods: []string{"POST"},
AllowHeaders: []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
ExposeHeaders: []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
AllowCredentials: true,
}))
if beego.BConfig.RunMode == "dev" {
beego.BConfig.WebConfig.DirectoryIndex = true
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
}
Init()
beego.Run()
}
func Init() {
svconst.AppName = beego.AppConfig.String("appname")
svlog.Init()
svlog.InitAliLog(svconst.AppName)
if !svredis.Init() {
return
}
if !svmysql.Init() {
return
}
//// 初始化数数打点
//_ = thinkingdata.InitThinkData()
//
//_ = config.InitLxLimit()
if !svconfig.Init() {
return
}
if !configs.Init() {
return
}
svdto.Init()
// 初始化配置
cardholder.Init()
}