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

Support multi registrations for custom http errors #674

Closed
kataras opened this issue Jul 16, 2017 · 0 comments
Closed

Support multi registrations for custom http errors #674

kataras opened this issue Jul 16, 2017 · 0 comments

Comments

@kataras
Copy link
Owner

kataras commented Jul 16, 2017

The problem

The problem is with app.OnErrorCode(404, ... we can register only one handler, that issue can be solved by wrapping handlers together, it's basic functional way to do it, but then we have second problem

Middleware, the second problem

Today we can add middleware to custom errors by calling them manually inside our custom handler, i.,e func(ctx context.Context){ myErrMiddlewre(ctx); myErrHandler(ctx) }.

The ctx.Next() inside these handlers will not be managed correctly, so wrapping handlers for these kind of things is not a solution for apps who depends on middlewares that are specific registered to error handlers.

Solution

Both issues can be solved by allowing registration of multiple Handlers for a specific http error.
i.e app.OnErrorCode(404, myErrMiddleware, myErrHandler) , the ctx.Next() will be respected, so if the myErrMiddleware isn't calling the ctx.Next() then myErrHandler will be not executed, as expected.

Completed

With fe256fe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant