Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update timeout.md #222

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions website/content/middleware/timeout.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Timeout middleware is used to timeout at a long running operation within a prede
e := echo.New()
e.Use(middleware.TimeoutWithConfig(middleware.TimeoutConfig{
Skipper: Skipper,
ErrorHandler: func(err error, e echo.Context) error {
OnTimeoutRouteErrorHandler: func(err error, e echo.Context) error {
// you can handle your error here, the returning error will be
// passed down the middleware chain
return err
Expand All @@ -36,28 +36,23 @@ e.Use(middleware.TimeoutWithConfig(middleware.TimeoutConfig{
TimeoutConfig struct {
// Skipper defines a function to skip middleware.
Skipper Skipper
// ErrorHandler defines a function which is executed for a timeout
// It can be used to define a custom timeout error
ErrorHandler TimeoutErrorHandlerWithContext
// ErrorMessage is written to response on timeout in addition to http.StatusServiceUnavailable (503) status code
// It can be used to define a custom timeout error message
ErrorMessage string
// OnTimeoutRouteErrorHandler is an error handler that is executed for error that was returned
// from wrapped route after OnTimeoutRouteErrorHandler func(err error, c echo.Context)
OnTimeoutRouteErrorHandler func(err error, c echo.Context)
// Timeout configures a timeout for the middleware, defaults to 0 for no timeout
Timeout time.Duration
}
```

*TimeoutErrorHandlerWithContext* is responsible for handling the errors when a timeout happens
```go
// TimeoutErrorHandlerWithContext is an error handler that is used
// with the timeout middleware so we can handle the error
// as we see fit
TimeoutErrorHandlerWithContext func(error, echo.Context) error
```

*Default Configuration*

```go
DefaultTimeoutConfig = TimeoutConfig{
Skipper: DefaultSkipper,
Timeout: 0,
ErrorHandler: nil,
ErrorMessage: "",
}
```