From 4a3d32dc1fed75b9acd5517ae8cf15198bc7d5e0 Mon Sep 17 00:00:00 2001 From: astaxie Date: Sun, 22 Sep 2013 11:43:22 +0800 Subject: [PATCH] support auto get session from input fix #211 --- controller.go | 2 +- router.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/controller.go b/controller.go index 491b9610..1a35ca1b 100644 --- a/controller.go +++ b/controller.go @@ -270,7 +270,7 @@ func (c *Controller) SaveToFile(fromfile, tofile string) error { func (c *Controller) StartSession() session.SessionStore { if c.CruSession == nil { - c.CruSession = GlobalSessions.SessionStart(c.Ctx.ResponseWriter, c.Ctx.Request) + c.CruSession = c.Ctx.Input.CruSession } return c.CruSession } diff --git a/router.go b/router.go index 211da029..f90d2be8 100644 --- a/router.go +++ b/router.go @@ -306,6 +306,10 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) context.Output = beecontext.NewOutput(rw) } + if SessionOn { + context.Input.CruSession = GlobalSessions.SessionStart(w, r) + } + var runrouter *controllerInfo var findrouter bool