modify cfg reference

This commit is contained in:
AllenX2018 2020-12-26 17:12:42 +08:00
parent 75849b6d6a
commit 3783847dce

View File

@ -246,7 +246,7 @@ func (p *ControllerRegister) addWithMethodParams(pattern string, c ControllerInt
route := &ControllerInfo{} route := &ControllerInfo{}
route.pattern = pattern route.pattern = pattern
route.routerType = routerTypeBeego route.routerType = routerTypeBeego
route.sessionOn = BConfig.WebConfig.Session.SessionOn route.sessionOn = p.cfg.WebConfig.Session.SessionOn
route.controllerType = t route.controllerType = t
route.initialize = func() ControllerInterface { route.initialize = func() ControllerInterface {
vc := reflect.New(route.controllerType) vc := reflect.New(route.controllerType)
@ -410,7 +410,7 @@ func (p *ControllerRegister) AddMethod(method, pattern string, f FilterFunc) {
route := &ControllerInfo{} route := &ControllerInfo{}
route.pattern = pattern route.pattern = pattern
route.routerType = routerTypeRESTFul route.routerType = routerTypeRESTFul
route.sessionOn = BConfig.WebConfig.Session.SessionOn route.sessionOn = p.cfg.WebConfig.Session.SessionOn
route.runFunction = f route.runFunction = f
methods := make(map[string]string) methods := make(map[string]string)
if method == "*" { if method == "*" {
@ -437,7 +437,7 @@ func (p *ControllerRegister) Handler(pattern string, h http.Handler, options ...
route := &ControllerInfo{} route := &ControllerInfo{}
route.pattern = pattern route.pattern = pattern
route.routerType = routerTypeHandler route.routerType = routerTypeHandler
route.sessionOn = BConfig.WebConfig.Session.SessionOn route.sessionOn = p.cfg.WebConfig.Session.SessionOn
route.handler = h route.handler = h
if len(options) > 0 { if len(options) > 0 {
if _, ok := options[0].(bool); ok { if _, ok := options[0].(bool); ok {
@ -472,7 +472,7 @@ func (p *ControllerRegister) AddAutoPrefix(prefix string, c ControllerInterface)
if !utils.InSlice(rt.Method(i).Name, exceptMethod) { if !utils.InSlice(rt.Method(i).Name, exceptMethod) {
route := &ControllerInfo{} route := &ControllerInfo{}
route.routerType = routerTypeBeego route.routerType = routerTypeBeego
route.sessionOn = BConfig.WebConfig.Session.SessionOn route.sessionOn = p.cfg.WebConfig.Session.SessionOn
route.methods = map[string]string{"*": rt.Method(i).Name} route.methods = map[string]string{"*": rt.Method(i).Name}
route.controllerType = ct route.controllerType = ct
pattern := path.Join(prefix, strings.ToLower(controllerName), strings.ToLower(rt.Method(i).Name), "*") pattern := path.Join(prefix, strings.ToLower(controllerName), strings.ToLower(rt.Method(i).Name), "*")
@ -778,7 +778,7 @@ func (p *ControllerRegister) serveHttp(ctx *beecontext.Context) {
} }
// session init // session init
currentSessionOn = BConfig.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 { if !currentSessionOn && originRouterInfo.sessionOn {