Skip to content

Commit

Permalink
feat: add redisEndpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
nomeguy committed Jun 3, 2024
1 parent b0ca44b commit 1d4179b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions conf/app.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ copyrequestbody = true
driverName = mysql
dataSourceName = root:123@tcp(localhost:3306)/
dbName = caswaf
redisEndpoint =
gatewayEnabled = true
gatewayHttpPort = 80
gatewayHttpsPort = 443
Expand Down
10 changes: 8 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package main
import (
"github.com/beego/beego"
"github.com/beego/beego/plugins/cors"
_ "github.com/beego/beego/session/redis"
"github.com/casbin/caswaf/casdoor"
"github.com/casbin/caswaf/object"
"github.com/casbin/caswaf/proxy"
Expand Down Expand Up @@ -51,8 +52,13 @@ func main() {
beego.InsertFilter("/*", beego.BeforeRouter, routers.TransparentStatic)
beego.InsertFilter("/api/*", beego.BeforeRouter, routers.ApiFilter)

beego.BConfig.WebConfig.Session.SessionProvider = "file"
beego.BConfig.WebConfig.Session.SessionProviderConfig = "./tmp"
if beego.AppConfig.String("redisEndpoint") == "" {
beego.BConfig.WebConfig.Session.SessionProvider = "file"
beego.BConfig.WebConfig.Session.SessionProviderConfig = "./tmp"
} else {
beego.BConfig.WebConfig.Session.SessionProvider = "redis"
beego.BConfig.WebConfig.Session.SessionProviderConfig = beego.AppConfig.String("redisEndpoint")
}
beego.BConfig.WebConfig.Session.SessionGCMaxLifetime = 3600 * 24 * 365

service.Start()
Expand Down

0 comments on commit 1d4179b

Please sign in to comment.