v01

package
v0.0.0-...-17c1655 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

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

func (e Event) CloudEventVersion() (version string)

CloudEventVersion returns the CloudEvents specification version supported by this implementation

func (Event) Get

func (e Event) Get(key string) (interface{}, bool)

Get gets a CloudEvent property value

func (Event) MarshalBinary

func (e Event) MarshalBinary(req *http.Request) error

MarshalBinary marshal an event in the binary representation

func (Event) MarshalJSON

func (e Event) MarshalJSON() ([]byte, error)

MarshalJSON marshal an event into json

func (Event) Properties

func (e Event) Properties() map[string]bool

Properties returns the map of all supported properties in version 0.1. The map value says whether particular property is required.

func (*Event) Set

func (e *Event) Set(key string, value interface{})

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

func (e *Event) UnmarshalBinary(req *http.Request) error

UnmarshalBinary unmarshal an event into the binary representation

func (*Event) UnmarshalJSON

func (e *Event) UnmarshalJSON(b []byte) error

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

func (HTTPMarshaller) ToRequest

func (e HTTPMarshaller) ToRequest(req *http.Request, event cloudevents.Event) error

ToRequest populates an http Request with the given CloudEvent

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL