-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
feat: Add a new ErrorHandlerWithContext #1328
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
Conversation
This commit adds a new error handler, which is passed the current context, so that you can add custom redirects or even other kinds of responses. For example: ```go e.Use(middleware.JWTWithConfig(middleware.JWTConfig{ SigningKey: []byte("secret"), TokenLookup: "query:token", ErrorHandlerWithContext: func(err error, c echo.Context) error { // do stuff with context and err switch err.(type) { case jwt.ValidationError: return c.Redirect(http.StatusSeeOther, "/login") } return err }, })) ```
It seems like the build is failing because the script ran into some ratelimiter of the googleapi. If someone with access to the travis-ci project could retrigger the build. That would be neat! |
Bump |
@tomscholz Can this be achieved via a custom http handler? |
Somebody seems to think the same as me. |
@TomLiu-GitHub, @tomscholz I can understand the sentiment but if you look at this change, it should/can be applied to all the middleware, isn't it? |
@vishr after a quick look I don't see this change necessary for all middlewares, but if the middleware has an option for a custom error handler, it can be useful and should be evaluated |
For v5, I would like this to be merged with |
This commit adds a new error handler, which is passed the
current context, so that you can add custom redirects or even
other kinds of responses. For example:
What needs to be done, to get this merged?