forked from destory97/LanBlog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
33 lines (27 loc) · 882 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
package main
import (
_ "MyBlog/routers"
"github.com/astaxie/beego"
"github.com/astaxie/beego/orm"
"MyBlog/models"
"github.com/astaxie/beego/plugins/cors"
)
func init() {
models.RegisterDB()
orm.Debug=false
orm.RunSyncdb("default",false,true)
}
func main() {
beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
AllowAllOrigins: true,
AllowMethods: []string{"GET", "POST","OPTIONS"},
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"
}
beego.Run()
}