-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
31 lines (25 loc) · 839 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
package main
import (
_ "github.com/goldalworming/simple_kvdb/routers"
"github.com/astaxie/beego"
"github.com/astaxie/beego/plugins/cors"
"github.com/astaxie/beego/orm"
_ "github.com/go-sql-driver/mysql"
)
func init() {
orm.RegisterDataBase("default", "mysql", "root:root@tcp(127.0.0.1:3306)/kvdb")
}
func main() {
if beego.BConfig.RunMode == "dev" {
orm.Debug = true
}
beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
AllowOrigins: []string{"*"},
AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
AllowHeaders: []string{"Origin","Content-Type","Authorization", "Access-Control-Allow-Origin"},
ExposeHeaders: []string{"Content-Length", "Access-Control-Allow-Origin"},
AllowCredentials: true,
// MaxAge : time.Duration(10) * time.Minute,
}))
beego.Run()
}