NOISSUE - New error type for HTTP Proxy server to return Handlers error #50
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull request title should be
MF-XXX - description
orNOISSUE - description
where XXX is ID of issue that this PR relate to.Please review the CONTRIBUTING.md file for detailed contributing guidelines.
What does this do?
At present, Proxy handler return its own http status code.
There is no provision for handlers set return http status code.
This PR helps handlers to return http status code in error
Add new error type interface named
HTTPProxyError
is created, which return status code on calling methodStatusCode()
This can be used in
encodeError
to return If any error code returned by handlersThis feature was found during testing of this PR absmach/magistrala-old#257,
Where Things gRPC sends error warpped, but in result the HTTP Status is not as expected. Then found this kind of solution in handler will help us to send proper status code clients
Which issue(s) does this PR fix/relate to?
Put here
Resolves #XXX
to auto-close the issue that your PR fixes (if such)List any changes that modify/break current functionality
No
Have you included tests for your changes?
No, Not planned in this PR
Did you document any new/modified functionality?
No, Not planned in this PR
Notes
This error type helps to return http status code by handler, Example at here https://github.com/absmach/magistrala/blob/main/http/handler.go#L105-L168
We can implement like below with this new
HTTPPorxyError