3 // The session engine provides an interface to allow for storage of session data
5 SessionEngine interface {
6 Decode(c *Controller) // Called to decode the session information on the controller
7 Encode(c *Controller) // Called to encode the session information on the controller
12 sessionEngineMap = map[string]func() SessionEngine{}
13 CurrentSessionEngine SessionEngine
16 // Initialize session engine on startup
18 OnAppStart(initSessionEngine, 5)
21 func RegisterSessionEngine(f func() SessionEngine, name string) {
22 sessionEngineMap[name] = f
25 // Called when application is starting up
26 func initSessionEngine() {
27 // Check for session engine to use and assign it
28 sename := Config.StringDefault("session.engine", "revel-cookie")
29 if se, found := sessionEngineMap[sename]; found {
30 CurrentSessionEngine = se()
32 sessionLog.Warn("Session engine '%s' not found, using default session engine revel-cookie", sename)
33 CurrentSessionEngine = sessionEngineMap["revel-cookie"]()