-
Notifications
You must be signed in to change notification settings - Fork 89
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
Message ID can be int, string, or null as per OpenRPC spec #48
base: master
Are you sure you want to change the base?
Conversation
return nil | ||
} | ||
|
||
func (r requestID) MarshalJSON() ([]byte, error) { |
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.
You could add a sanity check here that "actual" is one of the three allowed Go types, just as an extra sanity check since UarshalJSON does it too.
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.
thanks @mvdan, added and it picked up a bug in my code! can you sanity check my latest commit to see if it's how you would have done it?
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.
SGTM. You could simplify it a little bit, since you don't need to separate the json.Marshal calls:
switch r.actual.(type) {
case nil, int64, string:
return json.Marshal(r.actual)
default:
return nil, fmt.Errorf("unexpected ID type: %T", r.actual)
}
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.
👍 thanks & done
Updated so all the |
@magik6k any chance of getting some eyes on this? I know it's not a trivial change but it'd be nice to be able to support OpenRPC properly. |
Fixes: #28