-
Notifications
You must be signed in to change notification settings - Fork 2
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
SCT-156 Build: ErrorHandlerMiddleware pattern in Bean framework #28
Conversation
internal/project/framework/bean.go
Outdated
errorHandlerMiddlewares := concatErrorHandlerMiddlewares(b.errorHandlerMiddlewares, | ||
berror.ValidationErrorHanderMiddleware, | ||
berror.APIErrorHanderMiddleware, | ||
berror.HTTPErrorHanderMiddleware, | ||
berror.DefaultErrorHanderMiddleware) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can also use
b.UseErrorHandlerMiddleware(berror.ValidationErrorHanderMiddleware)
b.UseErrorHandlerMiddleware(berror.APIErrorHanderMiddleware)
...
then we don't need the concat function, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can also use
b.UseErrorHandlerMiddleware(berror.ValidationErrorHanderMiddleware) b.UseErrorHandlerMiddleware(berror.APIErrorHanderMiddleware) ...
then we don't need the concat function, right?
yes, but it make user don't need to think about framework errorHandlers, and it make less code in main.go
internal/project/framework/bean.go
Outdated
for _, m := range frameworkMiddlewares { | ||
middlewares = append(middlewares, m) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for _, m := range frameworkMiddlewares { | |
middlewares = append(middlewares, m) | |
} | |
middlewares = append(middlewares, frameworkMiddlewares...) |
error_middleware_test.go