Documentation
¶
Index ¶
- func NewBinaryHTTPCloudEventConverter() cloudevents.HTTPCloudEventConverter
- func NewDefaultHTTPMarshaller() cloudevents.HTTPMarshaller
- func NewHTTPMarshaller(converters ...cloudevents.HTTPCloudEventConverter) cloudevents.HTTPMarshaller
- func NewJSONHTTPCloudEventConverter() cloudevents.HTTPCloudEventConverter
- type Event
- func (e Event) CloudEventVersion() (version string)
- func (e Event) Get(key string) (interface{}, bool)
- func (e Event) MarshalBinary(req *http.Request) error
- func (e Event) MarshalJSON() ([]byte, error)
- func (e Event) Properties() map[string]bool
- func (e *Event) Set(key string, value interface{})
- func (e *Event) UnmarshalBinary(req *http.Request) error
- func (e *Event) UnmarshalJSON(b []byte) error
- type HTTPFormat
- type HTTPMarshaller
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBinaryHTTPCloudEventConverter ¶
func NewBinaryHTTPCloudEventConverter() cloudevents.HTTPCloudEventConverter
NewBinaryHTTPCloudEventConverter creates a new BinaryHTTPCloudEventConverter
func NewDefaultHTTPMarshaller ¶
func NewDefaultHTTPMarshaller() cloudevents.HTTPMarshaller
NewDefaultHTTPMarshaller creates a new v01 HTTPMarshaller prepopulated with the Binary and JSON CloudEvent converters
func NewHTTPMarshaller ¶
func NewHTTPMarshaller(converters ...cloudevents.HTTPCloudEventConverter) cloudevents.HTTPMarshaller
NewHTTPMarshaller creates a new HTTPMarshaller with the given HTTPCloudEventConverters
func NewJSONHTTPCloudEventConverter ¶
func NewJSONHTTPCloudEventConverter() cloudevents.HTTPCloudEventConverter
NewJSONHTTPCloudEventConverter creates a new JSONHTTPCloudEventConverter
Types ¶
type Event ¶
type Event struct {
// CloudEventsVersion is a mandatory property
// https://github.com/cloudevents/spec/blob/v0.1/spec.md#cloudeventsversion
CloudEventsVersion string `json:"cloudEventsVersion" cloudevents:"CE-CloudEventsVersion,required"`
// EventType is a mandatory property
// https://github.com/cloudevents/spec/blob/v0.1/spec.md#eventtype
EventType string `json:"eventType" cloudevents:"CE-EventType,required"`
// EventTypeVersion is an optional property
// https://github.com/cloudevents/spec/blob/v0.1/spec.md#eventtypeversion
EventTypeVersion string `json:"eventTypeVersion,omitempty" cloudevents:"CE-EventTypeVersion"`
// Source is a mandatory property
// TODO: ensure URI parsing
// https://github.com/cloudevents/spec/blob/v0.1/spec.md#source
Source string `json:"source" cloudevents:"CE-Source,required"`
// EventID is a mandatory property
// https://github.com/cloudevents/spec/blob/v0.1/spec.md#eventid
EventID string `json:"eventID" cloudevents:"CE-EventID,required"`
// EventTime is an optional property
// https://github.com/cloudevents/spec/blob/v0.1/spec.md#eventtime
EventTime *time.Time `json:"eventTime,omitempty" cloudevents:"CE-EventTime"`
// SchemaURL is an optional property
// https://github.com/cloudevents/spec/blob/v0.1/spec.md#schemaurl
SchemaURL string `json:"schemaURL,omitempty" cloudevents:"CE-SchemaURL"`
// ContentType is an optional property
// https://github.com/cloudevents/spec/blob/v0.1/spec.md#contenttype
ContentType string `json:"contentType,omitempty" cloudevents:"Content-Type"`
// Data is an optional property
// https://github.com/cloudevents/spec/blob/v0.1/spec.md#data-1
Data interface{} `json:"data,omitempty" cloudevents:",body"`
// contains filtered or unexported fields
}
Event implements the the CloudEvents specification version 0.1 https://github.com/cloudevents/spec/blob/v0.1/spec.md
func (Event) CloudEventVersion ¶
CloudEventVersion returns the CloudEvents specification version supported by this implementation
func (Event) MarshalBinary ¶
MarshalBinary marshal an event in the binary representation
func (Event) MarshalJSON ¶
MarshalJSON marshal an event into json
func (Event) Properties ¶
Properties returns the map of all supported properties in version 0.1. The map value says whether particular property is required.
func (*Event) Set ¶
Set sets a CloudEvent property value. If setting a well known field the type of value must be assignable to the type of the well known field.
func (*Event) UnmarshalBinary ¶
UnmarshalBinary unmarshal an event into the binary representation
func (*Event) UnmarshalJSON ¶
UnmarshalJSON override default json unmarshall
type HTTPFormat ¶
type HTTPFormat string
HTTPFormat type wraps supported modes of formatting CloudEvent as HTTP request. Currently, only binary mode and structured mode with JSON encoding are supported.
const ( // FormatBinary corresponds to Binary mode in CloudEvents HTTP transport binding. // https://github.com/cloudevents/spec/blob/a12b6b618916c89bfa5595fc76732f07f89219b5/http-transport-binding.md#31-binary-content-mode FormatBinary HTTPFormat = "binary" // FormatJSON corresponds to Structured mode using JSON encoding. // https://github.com/cloudevents/spec/blob/a12b6b618916c89bfa5595fc76732f07f89219b5/http-transport-binding.md#32-structured-content-mode FormatJSON HTTPFormat = "json" )
type HTTPMarshaller ¶
type HTTPMarshaller struct {
// contains filtered or unexported fields
}
HTTPMarshaller A struct representing the v01 version of the HTTPMarshaller
func (HTTPMarshaller) FromRequest ¶
func (e HTTPMarshaller) FromRequest(req *http.Request) (cloudevents.Event, error)
FromRequest creates a new CloudEvent from an http Request