Skip to content

Commit

Permalink
Enhancement pack for next release
Browse files Browse the repository at this point in the history
Added session engine support, and the session cookie engine
breaking change revel.Session was map[string]string now is map[string]interface{}
  • Loading branch information
notzippy committed Oct 8, 2018
1 parent 93d7ca8 commit 577ae8b
Show file tree
Hide file tree
Showing 12 changed files with 757 additions and 244 deletions.
21 changes: 11 additions & 10 deletions controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"strings"
"time"

"github.com/revel/revel/session"
"github.com/revel/revel/logger"
)

Expand All @@ -34,13 +35,13 @@ type Controller struct {
Response *Response
Result Result

Flash Flash // User cookie, cleared after 1 request.
Session Session // Session, stored in cookie, signed.
Params *Params // Parameters from URL and form (including multipart).
Args map[string]interface{} // Per-request scratch space.
ViewArgs map[string]interface{} // Variables passed to the template.
Validation *Validation // Data validation helpers
Log logger.MultiLogger // Context Logger
Flash Flash // User cookie, cleared after 1 request.
Session session.Session // Session, stored using the session engine specified
Params *Params // Parameters from URL and form (including multipart).
Args map[string]interface{} // Per-request scratch space.
ViewArgs map[string]interface{} // Variables passed to the template.
Validation *Validation // Data validation helpers
Log logger.MultiLogger // Context Logger
}

// The map of controllers, controllers are mapped by using the namespace|controller_name as the key
Expand Down Expand Up @@ -103,7 +104,7 @@ func (c *Controller) Destroy() {
c.ClientIP = ""
c.Result = nil
c.Flash = Flash{}
c.Session = Session{}
c.Session = session.NewSession()
c.Params = nil
c.Validation = nil
c.Log = nil
Expand Down Expand Up @@ -209,8 +210,8 @@ func (c *Controller) RenderTemplate(templatePath string) Result {
}

// TemplateOutput returns the result of the template rendered using the controllers ViewArgs.
func (c *Controller) TemplateOutput(templatePath string) (data []byte,err error) {
return TemplateOutputArgs(templatePath,c.ViewArgs)
func (c *Controller) TemplateOutput(templatePath string) (data []byte, err error) {
return TemplateOutputArgs(templatePath, c.ViewArgs)
}

// RenderJSON uses encoding/json.Marshal to return JSON to the client.
Expand Down
194 changes: 0 additions & 194 deletions session.go

This file was deleted.

11 changes: 11 additions & 0 deletions session/init.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package session

// The logger for the session
import "github.com/revel/revel/logger"

var sessionLog logger.MultiLogger

func InitSession(coreLogger logger.MultiLogger) {
sessionLog = coreLogger.New("section", "session")
}

Loading

0 comments on commit 577ae8b

Please sign in to comment.