move route sessionOn calculate to router adding
This commit is contained in:
parent
3783847dce
commit
dd35e4b1b2
@ -275,6 +275,13 @@ func (p *ControllerRegister) addWithMethodParams(pattern string, c ControllerInt
|
|||||||
for i := range opts {
|
for i := range opts {
|
||||||
opts[i](route)
|
opts[i](route)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
globalSessionOn := p.cfg.WebConfig.Session.SessionOn
|
||||||
|
if !globalSessionOn && route.sessionOn {
|
||||||
|
logs.Warn("global sessionOn is false, sessionOn of router [%s] can't be set to true", route.pattern)
|
||||||
|
route.sessionOn = globalSessionOn
|
||||||
|
}
|
||||||
|
|
||||||
p.addRouterForMethod(route)
|
p.addRouterForMethod(route)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -781,11 +788,7 @@ func (p *ControllerRegister) serveHttp(ctx *beecontext.Context) {
|
|||||||
currentSessionOn = p.cfg.WebConfig.Session.SessionOn
|
currentSessionOn = p.cfg.WebConfig.Session.SessionOn
|
||||||
originRouterInfo, originFindRouter = p.FindRouter(ctx)
|
originRouterInfo, originFindRouter = p.FindRouter(ctx)
|
||||||
if originFindRouter {
|
if originFindRouter {
|
||||||
if !currentSessionOn && originRouterInfo.sessionOn {
|
currentSessionOn = originRouterInfo.sessionOn
|
||||||
logs.Warn("global sessionOn is false, sessionOn of router [%s] %s can't be set to true", ctx.Request.Method, ctx.Request.URL.Path)
|
|
||||||
} else {
|
|
||||||
currentSessionOn = originRouterInfo.sessionOn
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if currentSessionOn {
|
if currentSessionOn {
|
||||||
ctx.Input.CruSession, err = GlobalSessions.SessionStart(rw, r)
|
ctx.Input.CruSession, err = GlobalSessions.SessionStart(rw, r)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user