|
12345678910111213141516171819202122232425262728293031 |
- package main
-
- import (
- "github.com/astaxie/beego"
- "github.com/astaxie/beego/plugins/cors"
- "github.com/casbin/casvisor/routers"
-
- _ "github.com/casbin/casvisor/routers"
- )
-
- func main() {
- beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
- AllowOrigins: []string{"*"},
- AllowMethods: []string{"GET", "PUT", "PATCH"},
- AllowHeaders: []string{"Origin"},
- 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()
- }
|