(from previous commit) fix sessions init when UseDatabaseDB before session manager

This commit is contained in:
Gerasimos Maropoulos 2016-09-04 22:09:54 +03:00
parent b8b52ad46e
commit 27e21d2685

12
iris.go
View File

@ -232,14 +232,17 @@ func New(cfg ...config.Iris) *Framework {
return s return s
} }
func (s *Framework) initialize() { func (s *Framework) initSessions() {
// set the sessions // set the sessions
if s.Config.Sessions.Cookie != "" { if s.sessions == nil && s.Config.Sessions.Cookie != "" {
//set the session manager //set the session manager
s.sessions = fasthttpSessions.New(fasthttpSessions.Config(s.Config.Sessions)) s.sessions = fasthttpSessions.New(fasthttpSessions.Config(s.Config.Sessions))
} }
}
func (s *Framework) initialize() {
s.initSessions()
// prepare the response engines, if no response engines setted for the default content-types // prepare the response engines, if no response engines setted for the default content-types
// then add them // then add them
@ -600,6 +603,9 @@ func UseSessionDB(db sessions.Database) {
// //
// Note: Don't worry if no session database is registered, your context.Session will continue to work. // Note: Don't worry if no session database is registered, your context.Session will continue to work.
func (s *Framework) UseSessionDB(db sessions.Database) { func (s *Framework) UseSessionDB(db sessions.Database) {
if s.sessions == nil {
s.initSessions()
}
s.sessions.UseDatabase(db) s.sessions.UseDatabase(db)
} }