From 76522d43af8ac4b1d5d4c9788616263e4c956cdf Mon Sep 17 00:00:00 2001 From: astaxie Date: Tue, 4 Nov 2014 19:07:49 +0800 Subject: [PATCH] simple the session --- router.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/router.go b/router.go index 4a4a934b..1f47c907 100644 --- a/router.go +++ b/router.go @@ -644,7 +644,13 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) // session init if SessionOn { - context.Input.CruSession = GlobalSessions.SessionStart(w, r) + var err error + context.Input.CruSession, err = GlobalSessions.SessionStart(w, r) + if err != nil { + Error(err) + middleware.Exception("503", rw, r, "") + return + } defer func() { context.Input.CruSession.SessionRelease(w) }() @@ -888,6 +894,11 @@ func (p *ControllerRegistor) recoverPanic(rw http.ResponseWriter, r *http.Reques if handler, ok := middleware.ErrorMaps[fmt.Sprint(err)]; ok { handler(rw, r) return + } else if handler, ok := middleware.ErrorMaps["503"]; ok { + handler(rw, r) + return + } else { + rw.Write([]byte(fmt.Sprint(err))) } } else { Critical("the request url is ", r.URL.Path)