-
Notifications
You must be signed in to change notification settings - Fork 219
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
Support content types following structured syntax suffixes #1007
Conversation
2617113
to
d6764a3
Compare
d6764a3
to
bc1a952
Compare
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.
/LGTM
ping @lionelvillard @embano1
bc1a952
to
595c306
Compare
595c306
to
410c767
Compare
Hi @dan-j @duglin ! So what's the relationship between the AddStructuredSuffixDecoder and the structured mode? It seems they are describing two kinds of different things, if so, I suggest using another name that won't cause any ambiguity to register the encoder and decoder. Thanks! |
Hi @yanmxa, the The var e cloudevent.Event
var target MyStruct
_ = e.DataAs(&target) "Structure Syntax Suffix" is the formal name for this technique, as documented here: https://www.iana.org/assignments/media-type-structured-suffix/media-type-structured-suffix.xhtml. We could rename the functions I've also tried to explain this in the GoDoc for the functions, if you have a way to better word this then I'm happy for some feedback. |
Since "Structure Syntax Suffix" is a conventional formal name for it. Using any other name seems to break the original meaning, and I agree with you that we can clarify it in the comments on the methods. @dan-j Thanks for your clarification! |
This enables the encoding/decoding of custom content types which use the `+json` or `+xml` suffix to indicate that their encoding is JSON or XML respectively. Users can also add their own suffixes to the registry in a similar fashion to how `datacodec.AddDecoder()` and `dataodec.AddEncoder()` work, but via the `AddStructuredSuffixDecoder` and `AddStructuredSuffixEncoder` functions. Signed-off-by: dan-j <[email protected]>
030c702
to
c68ed0e
Compare
See #990, this adds support for encoding/decoding cloudevent data which is defined by a content-type following the Structured Syntax Suffixes standard.
This enables the encoding/decoding of custom content types which use the
+json
or+xml
suffix to indicate that their encoding is JSON or XML respectively. Users can also add their own suffixes to the registry in a similar fashion to howdatacodec.AddDecoder()
anddataodec.AddEncoder()
work, but via theAddStructuredSuffixDecoder
andAddStructuredSuffixEncoder
functions.Fixes #990