made session, flash, work(ish)

This commit is contained in:
2018-04-07 19:56:42 +01:00
parent b8f8c995c1
commit 98fad75b95
6 changed files with 41 additions and 37 deletions
+7 -2
View File
@@ -12,7 +12,7 @@ import (
"github.com/sirupsen/logrus"
)
func (a *App) newContext(r Route, res http.ResponseWriter, req *http.Request) *DefaultContext {
func newContext(r Route, res http.ResponseWriter, req *http.Request) *DefaultContext {
data := make(map[string]interface{})
data["path"] = r.Path
data["env"] = r.Env
@@ -23,7 +23,7 @@ func (a *App) newContext(r Route, res http.ResponseWriter, req *http.Request) *D
params.Set(k, v)
}
sessionStore, _ := a.cfg.SessionStore.Get(req, a.cfg.SessionName)
sessionStore, _ := r.Session.Get(req, r.SessionName)
session := &Session{
Session: sessionStore,
req: req,
@@ -110,6 +110,11 @@ func (d *DefaultContext) Render(status int, rr render.Renderer) error {
return err
}
if d.Session() != nil {
d.Flash().Clear()
d.Flash().persist(d.Session())
}
d.Response().Header().Set("Content-Type", rr.ContentType())
d.Response().WriteHeader(status)
_, err = io.Copy(d.Response(), bb)