Skip to content

Reference

Page What it holds
Errors Every sentinel, when it is returned, and what to do about it
CloudEvents wire format go/envelope-cloudevents: every header, each binding's prefix, structured mode, and how Read chooses

The Go API itself is on pkg.go.dev:

type Event struct { /* eight attributes, Extensions, Data */ }
const SpecVersion = "1.0"

func Validate(e Event) error
func ValidExtensionName(name string) bool

type Format interface {
    Encode(Event) (Wire, error)
    Recognises(w Wire) bool
    Decode(Wire) (Event, Foreign, error)
}

type Wire struct {
    ContentType string
    Headers     map[string][]string
    Body        []byte
}

type Foreign struct {
    Headers   map[string][]string
    Conflicts []string
}

func Read(w Wire, formats ...Format) (Event, Foreign, Format, error)