From b9fdbdf7b5a11779686bb9f59661d1526cd3231c Mon Sep 17 00:00:00 2001 From: astaxie Date: Mon, 16 Dec 2013 23:22:15 +0800 Subject: [PATCH] use StopRun to terminate the execution --- controller.go | 2 +- router.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/controller.go b/controller.go index d5be2ef0..b3b3577f 100644 --- a/controller.go +++ b/controller.go @@ -181,7 +181,7 @@ func (c *Controller) Abort(code string) { } func (c *Controller) StopRun() { - panic("") + panic("StopRun") } func (c *Controller) UrlFor(endpoint string, values ...string) string { diff --git a/router.go b/router.go index 94f4279f..2bc14a87 100644 --- a/router.go +++ b/router.go @@ -369,6 +369,9 @@ func (p *ControllerRegistor) UrlFor(endpoint string, values ...string) string { func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) { defer func() { if err := recover(); err != nil { + if fmt.Sprint(err) == "StopRun" { + return + } if _, ok := err.(middleware.HTTPException); ok { // catch intented errors, only for HTTP 4XX and 5XX } else {