diff options
author | Wim <wim@42.be> | 2021-05-05 22:03:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-05 22:03:28 +0200 |
commit | a0bca42a7ad98a37f4bdc4d7adc419471163edfb (patch) | |
tree | 3e87fdb61128039b016adb4e586636484c63ed52 /vendor/github.com/labstack/echo/v4/middleware/timeout.go | |
parent | af543dcd05cfb5341311e2e214727e26411d2f92 (diff) | |
download | matterbridge-msglm-a0bca42a7ad98a37f4bdc4d7adc419471163edfb.tar.gz matterbridge-msglm-a0bca42a7ad98a37f4bdc4d7adc419471163edfb.tar.bz2 matterbridge-msglm-a0bca42a7ad98a37f4bdc4d7adc419471163edfb.zip |
Update vendor (#1461)
* Update vendored libs
* Fix slack api changes
Diffstat (limited to 'vendor/github.com/labstack/echo/v4/middleware/timeout.go')
-rw-r--r-- | vendor/github.com/labstack/echo/v4/middleware/timeout.go | 9 |
1 files changed, 7 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 68f464e4..5d23ff45 100644 --- a/vendor/github.com/labstack/echo/v4/middleware/timeout.go +++ b/vendor/github.com/labstack/echo/v4/middleware/timeout.go @@ -42,8 +42,8 @@ var ( } ) -// Timeout returns a middleware which recovers from panics anywhere in the chain -// and handles the control to the centralized HTTPErrorHandler. +// Timeout returns a middleware which returns error (503 Service Unavailable error) to client immediately when handler +// call runs for longer than its time limit. NB: timeout does not stop handler execution. func Timeout() echo.MiddlewareFunc { return TimeoutWithConfig(DefaultTimeoutConfig) } @@ -106,6 +106,11 @@ func (t echoHandlerFuncWrapper) ServeHTTP(rw http.ResponseWriter, r *http.Reques // so on timeout writer stays what http.TimeoutHandler uses and prevents writing headers/body t.ctx.Response().Writer = originalWriter if err != nil { + // call global error handler to write error to the client. This is needed or `http.TimeoutHandler` will send status code by itself + // and after that our tries to write status code will not work anymore + t.ctx.Error(err) + // we pass error from handler to middlewares up in handler chain to act on it if needed. But this means that + // global error handler is probably be called twice as `t.ctx.Error` already does that. t.errChan <- err } } |