Documentation
¶
Overview ¶
Package cloudevents provides encoding and decoding helpers for CloudEvents 1.0. It converts events.Event to/from the CloudEvents structured-content-mode JSON envelope and the binary-content-mode HTTP representation.
Pure stdlib — no third-party dependencies.
Index ¶
Constants ¶
const ContentType = "application/cloudevents+json"
ContentType is the HTTP Content-Type for structured-mode CloudEvents.
Variables ¶
This section is empty.
Functions ¶
func BinaryDecode ¶
BinaryDecode reconstructs an Event from CloudEvents 1.0 binary-content-mode HTTP headers and the request body.
func BinaryEncode ¶
BinaryEncode sets CloudEvents 1.0 binary-content-mode headers on h and returns the data bytes for the request body. Set the Content-Type header separately using e.DataType (usually "application/json").
Types ¶
type StructuredEnvelope ¶
type StructuredEnvelope struct {
// CloudEvents 1.0 core attributes
SpecVersion string `json:"specversion"`
ID string `json:"id"`
Source string `json:"source"`
Type string `json:"type"`
Subject string `json:"subject,omitempty"`
Time time.Time `json:"time"`
DataContentType string `json:"datacontenttype,omitempty"`
Data json.RawMessage `json:"data,omitempty"`
// maniflex extension attributes (prefixed with "x" per CE spec)
Xmodel string `json:"xmodel,omitempty"`
Xoperation string `json:"xoperation,omitempty"`
Xrecordid string `json:"xrecordid,omitempty"`
Xactorid string `json:"xactorid,omitempty"`
Xtenantid string `json:"xtenantid,omitempty"`
Xtraceid string `json:"xtraceid,omitempty"`
Xschemaver int `json:"xschemaver,omitempty"`
}
StructuredEnvelope is the CloudEvents 1.0 structured-content-mode JSON body. The Content-Type of the HTTP body must be "application/cloudevents+json".