main.go
1000 Bytes
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
package main
import (
"apigame/models"
_ "apigame/routers"
ht_draw "apigame/service/ht-cardholder"
"fmt"
"github.com/astaxie/beego"
"github.com/astaxie/beego/plugins/cors"
)
func main() {
fmt.Println("apigame")
//fmt.Println("😊🐸😺")
//解决跨域问题
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"
}
_ = models.Inits()
// 初始化配置
ht_draw.Init()
beego.Run()
}