-
Notifications
You must be signed in to change notification settings - Fork 21
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
[#67] Fix Client's ReadResource method #68
[#67] Fix Client's ReadResource method #68
Conversation
[metoro-io#63] Fix HTTP transport by removing duplication of base transport
@@ -85,14 +85,51 @@ type EmbeddedResource struct { | |||
|
|||
// Custom JSON marshaling for EmbeddedResource | |||
func (c EmbeddedResource) MarshalJSON() ([]byte, error) { | |||
type wrapper struct { |
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.
The changes in this file are written to satisfy the following constraint:
- Don't break the existing marshaling/unmarshaling API for
EmbeddedResource
.- Add an
embeddedResourceType
field (don't touch existing fields). - Continue to allow the multiple content types and schemas (
BlobResourceContents
,TextResourceContents
) over one endpoint.
- Add an
switch c.EmbeddedResourceType { | ||
case embeddedResourceTypeText: | ||
c.TextResourceContents = new(TextResourceContents) | ||
return json.Unmarshal(wrapper.Raw, c.TextResourceContents) |
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.
I don't like unmarshaling twice, but given the API supports multiple types/schemas that are identified in the body (not in headers), I don't currently see a way around it.
Temporarily have to close this due to company OSS policies |
Pre-requisite
Review/merge #66, first.
Issue
#67
Explanation of bug
The
Client
's currentReadResource()
method does not correctly parse the response from the Protocol's request to theServer
.That response, returned by the
Server
, is ultimately enforced to be of type *ResourceResponse when the resource is registered at server startup. This type differs from what theClient
is currently written to expect.Solution
Updated the
Client
'sReadResponse()
method to expect type*ResourceResponse
.I can now set up the server, locally, with:
And I can run the client, locally:
Running the client outputs: