summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/labstack/echo/v4/middleware/timeout.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/labstack/echo/v4/middleware/timeout.go')
-rw-r--r--vendor/github.com/labstack/echo/v4/middleware/timeout.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/vendor/github.com/labstack/echo/v4/middleware/timeout.go b/vendor/github.com/labstack/echo/v4/middleware/timeout.go
index 5d23ff45..fb8ae421 100644
--- a/vendor/github.com/labstack/echo/v4/middleware/timeout.go
+++ b/vendor/github.com/labstack/echo/v4/middleware/timeout.go
@@ -1,5 +1,3 @@
-// +build go1.13
-
package middleware
import (
@@ -94,6 +92,15 @@ func (t echoHandlerFuncWrapper) ServeHTTP(rw http.ResponseWriter, r *http.Reques
originalWriter := t.ctx.Response().Writer
t.ctx.Response().Writer = rw
+ // in case of panic we restore original writer and call panic again
+ // so it could be handled with global middleware Recover()
+ defer func() {
+ if err := recover(); err != nil {
+ t.ctx.Response().Writer = originalWriter
+ panic(err)
+ }
+ }()
+
err := t.handler(t.ctx)
if ctxErr := r.Context().Err(); ctxErr == context.DeadlineExceeded {
if err != nil && t.errHandler != nil {