Documentation
¶
Overview ¶
Package datacodec holds the data codec registry and adds known encoders and decoders supporting media types such as `application/json` and `application/xml`.
Index ¶
- func AddDecoder(contentType string, fn Decoder)
- func AddEncoder(contentType string, fn Encoder)
- func AddStructuredSuffixDecoder(suffix string, fn Decoder)
- func AddStructuredSuffixEncoder(suffix string, fn Encoder)
- func Decode(ctx context.Context, contentType string, in []byte, out interface{}) error
- func Encode(ctx context.Context, contentType string, in interface{}) ([]byte, error)
- type Decoder
- type Encoder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddDecoder ¶
AddDecoder registers a decoder for a given content type. The codecs will use these to decode the data payload from a cloudevent.Event object.
func AddEncoder ¶
AddEncoder registers an encoder for a given content type. The codecs will use these to encode the data payload for a cloudevent.Event object.
func AddStructuredSuffixDecoder ¶ added in v2.16.0
AddStructuredSuffixDecoder registers a decoder for content-types which match the given structured syntax suffix as defined by [Structured Syntax Suffixes](https://www.iana.org/assignments/media-type-structured-suffix/media-type-structured-suffix.xhtml). This allows users to register custom decoders for non-standard content types which follow the structured syntax suffix standard (e.g. application/vnd.custom-app+json).
Suffix should not include the "+" character, and "json" and "xml" are registered by default.
func AddStructuredSuffixEncoder ¶ added in v2.16.0
AddStructuredSuffixEncoder registers an encoder for content-types which match the given structured syntax suffix as defined by [Structured Syntax Suffixes](https://www.iana.org/assignments/media-type-structured-suffix/media-type-structured-suffix.xhtml). This allows users to register custom encoders for non-standard content types which follow the structured syntax suffix standard (e.g. application/vnd.custom-app+json).
Suffix should not include the "+" character, and "json" and "xml" are registered by default.
Types ¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package json holds the encoder/decoder implementation for `application/json`.
|
Package json holds the encoder/decoder implementation for `application/json`. |
|
Package text holds the encoder/decoder implementation for `text/plain`.
|
Package text holds the encoder/decoder implementation for `text/plain`. |
|
Package xml holds the encoder/decoder implementation for `application/xml`.
|
Package xml holds the encoder/decoder implementation for `application/xml`. |