76522d43 by astaxie

simple the session

1 parent 52df1234
Showing 1 changed file with 12 additions and 1 deletions
...@@ -644,7 +644,13 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) ...@@ -644,7 +644,13 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
644 644
645 // session init 645 // session init
646 if SessionOn { 646 if SessionOn {
647 context.Input.CruSession = GlobalSessions.SessionStart(w, r) 647 var err error
648 context.Input.CruSession, err = GlobalSessions.SessionStart(w, r)
649 if err != nil {
650 Error(err)
651 middleware.Exception("503", rw, r, "")
652 return
653 }
648 defer func() { 654 defer func() {
649 context.Input.CruSession.SessionRelease(w) 655 context.Input.CruSession.SessionRelease(w)
650 }() 656 }()
...@@ -888,6 +894,11 @@ func (p *ControllerRegistor) recoverPanic(rw http.ResponseWriter, r *http.Reques ...@@ -888,6 +894,11 @@ func (p *ControllerRegistor) recoverPanic(rw http.ResponseWriter, r *http.Reques
888 if handler, ok := middleware.ErrorMaps[fmt.Sprint(err)]; ok { 894 if handler, ok := middleware.ErrorMaps[fmt.Sprint(err)]; ok {
889 handler(rw, r) 895 handler(rw, r)
890 return 896 return
897 } else if handler, ok := middleware.ErrorMaps["503"]; ok {
898 handler(rw, r)
899 return
900 } else {
901 rw.Write([]byte(fmt.Sprint(err)))
891 } 902 }
892 } else { 903 } else {
893 Critical("the request url is ", r.URL.Path) 904 Critical("the request url is ", r.URL.Path)
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!