This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve response payload casting operation (#50)
`model.Message` struct has a method `CastPayloadToType` used to conveniently cast `Message.Payload.(Response).Payload` into the type of the provided argument. The current implementation had a few gaps that made the method only viaible in situations where `Message.Payload` were yet to be unmarshalled (e.g. `interface{} | []byte`). This PR also fixes a bug in rest_service.go where `RestServiceRequest.ResponseType` was never customizable, leading to the response body to be always treated like a JSON-decodable structure. This would cause HTTP calls whose response type is not of JSON to throw errors. By only deserializing the body for which the request header `Content-Type` is of JSON type and passing others as raw byte slices, the RestService callers can handle response payloads of arbitrary MIME types. Signed-off-by: Josh Kim <[email protected]>
- Loading branch information
Showing
3 changed files
with
97 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters