mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 10:41:03 +01:00
(from previous commit) fix sessions init when UseDatabaseDB before session manager
This commit is contained in:
parent
b8b52ad46e
commit
27e21d2685
12
iris.go
12
iris.go
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user