-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
37 lines (29 loc) · 829 Bytes
/
main.go
File metadata and controls
37 lines (29 loc) · 829 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 (
_ "abcode/routers"
"github.com/astaxie/beego/orm"
"github.com/astaxie/beego/plugins/cors"
"github.com/astaxie/beego"
_ "github.com/mattn/go-sqlite3"
)
func init() {
orm.RegisterDriver("sqlite3", orm.DRSqlite)
orm.RegisterDataBase("default", "sqlite3", "file:data.db")
}
func main() {
if beego.BConfig.RunMode == "dev" {
beego.BConfig.WebConfig.DirectoryIndex = true
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
}
err := orm.RunSyncdb("default", false, false)
if err != nil {
beego.Error(err)
}
beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
AllowOrigins: []string{"*"},
AllowMethods: []string{"GET","POST","PUT","DELETE"},
AllowCredentials: true,
//AllowHeaders: []string{"Origin", "Content-Type:application/json"},
}))
beego.Run()
}