You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.go 1.1 kB

3 years ago
3 years ago
3 years ago
1234567891011121314151617181920212223242526272829303132
  1. package main
  2. import (
  3. "github.com/astaxie/beego"
  4. "github.com/astaxie/beego/plugins/cors"
  5. "github.com/casbin/casvisor/object"
  6. "github.com/casbin/casvisor/routers"
  7. )
  8. func main() {
  9. object.InitAdapter()
  10. beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
  11. AllowOrigins: []string{"*"},
  12. AllowMethods: []string{"GET", "POST", "DELETE", "PUT", "PATCH", "OPTIONS"},
  13. AllowHeaders: []string{"Origin", "X-Requested-With", "Content-Type", "Accept"},
  14. ExposeHeaders: []string{"Content-Length"},
  15. AllowCredentials: true,
  16. }))
  17. //beego.DelStaticPath("/static")
  18. beego.SetStaticPath("/static", "web/build/static")
  19. // https://studygolang.com/articles/2303
  20. beego.InsertFilter("/", beego.BeforeRouter, routers.TransparentStatic) // must has this for default page
  21. beego.InsertFilter("/*", beego.BeforeRouter, routers.TransparentStatic)
  22. beego.BConfig.WebConfig.Session.SessionProvider = "file"
  23. beego.BConfig.WebConfig.Session.SessionProviderConfig = "./tmp"
  24. beego.BConfig.WebConfig.Session.SessionGCMaxLifetime = 3600 * 24 * 365
  25. beego.Run()
  26. }

No Description

Contributors (1)