You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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 problemMiddleware, 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)
, thectx.Next()
will be respected, so if themyErrMiddleware
isn't calling thectx.Next()
thenmyErrHandler
will be not executed, as expected.Completed
With fe256fe
The text was updated successfully, but these errors were encountered: