2016-05-30 16:08:09 +02:00
|
|
|
package sessions
|
|
|
|
|
|
|
|
import "github.com/kataras/iris/config"
|
|
|
|
|
|
|
|
// New creates & returns a new Manager and start its GC
|
|
|
|
func New(cfg ...config.Sessions) *Manager {
|
2016-06-14 07:45:40 +02:00
|
|
|
c := config.DefaultSessions().Merge(cfg)
|
|
|
|
// If provider is empty then return nil manager, means that the sessions are disabled
|
|
|
|
if c.Provider == "" {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
manager, err := newManager(c)
|
2016-05-30 16:08:09 +02:00
|
|
|
if err != nil {
|
|
|
|
panic(err.Error()) // we have to panic here because we will start GC after and if provider is nil then many panics will come
|
|
|
|
}
|
|
|
|
//run the GC here
|
|
|
|
go manager.GC()
|
|
|
|
return manager
|
|
|
|
}
|