openbrain/main.go

34 lines
1.1 KiB
Go
Raw Normal View History

2022-03-31 11:47:07 +08:00
package main
import (
"github.com/astaxie/beego"
"github.com/astaxie/beego/plugins/cors"
2022-04-16 20:53:36 +08:00
"github.com/openbrainorg/openbrain/object"
"github.com/openbrainorg/openbrain/routers"
_ "github.com/openbrainorg/openbrain/routers"
2022-03-31 11:47:07 +08:00
)
func main() {
2022-03-31 15:26:51 +08:00
object.InitAdapter()
2022-03-31 11:47:07 +08:00
beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
AllowOrigins: []string{"*"},
2022-03-31 15:26:51 +08:00
AllowMethods: []string{"GET", "POST", "DELETE", "PUT", "PATCH", "OPTIONS"},
AllowHeaders: []string{"Origin", "X-Requested-With", "Content-Type", "Accept"},
2022-03-31 11:47:07 +08:00
ExposeHeaders: []string{"Content-Length"},
AllowCredentials: true,
}))
//beego.DelStaticPath("/static")
beego.SetStaticPath("/static", "web/build/static")
// https://studygolang.com/articles/2303
beego.InsertFilter("/", beego.BeforeRouter, routers.TransparentStatic) // must has this for default page
beego.InsertFilter("/*", beego.BeforeRouter, routers.TransparentStatic)
beego.BConfig.WebConfig.Session.SessionProvider = "file"
beego.BConfig.WebConfig.Session.SessionProviderConfig = "./tmp"
beego.BConfig.WebConfig.Session.SessionGCMaxLifetime = 3600 * 24 * 365
beego.Run()
}