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

SCT-156 Build: ErrorHandlerMiddleware pattern in Bean framework #28

Merged
merged 3 commits into from
Jan 11, 2022

Conversation

gaoweiqiao-tre
Copy link
Contributor

@gaoweiqiao-tre gaoweiqiao-tre changed the title error handler middleware SCT-156 Build: ErrorHandlerMiddleware pattern in Bean framework Jan 7, 2022
Comment on lines 31 to 35
errorHandlerMiddlewares := concatErrorHandlerMiddlewares(b.errorHandlerMiddlewares,
berror.ValidationErrorHanderMiddleware,
berror.APIErrorHanderMiddleware,
berror.HTTPErrorHanderMiddleware,
berror.DefaultErrorHanderMiddleware)
Copy link
Contributor

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?

Copy link
Contributor Author

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

Comment on lines 68 to 70
for _, m := range frameworkMiddlewares {
middlewares = append(middlewares, m)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for _, m := range frameworkMiddlewares {
middlewares = append(middlewares, m)
}
middlewares = append(middlewares, frameworkMiddlewares...)

@tanvir-retailai tanvir-retailai merged commit c30574b into develop Jan 11, 2022
@tanvir-retailai tanvir-retailai deleted the feature/error-handler-middleware branch January 11, 2022 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants