v01

package
v0.0.0-...-ae859c0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	// EventType is a mandatory property
	// https://github.com/cloudevents/spec/blob/v0.1/spec.md#eventtype
	EventType string `json:"eventType"`
	// EventTypeVersion is an optional property
	// https://github.com/cloudevents/spec/blob/v0.1/spec.md#eventtypeversion
	EventTypeVersion string `json:"eventTypeVersion,omitempty"`
	// Source is a mandatory property
	// TODO: ensure URI parsing
	// https://github.com/cloudevents/spec/blob/v0.1/spec.md#source
	Source string `json:"source"`
	// EventID is a mandatory property
	// https://github.com/cloudevents/spec/blob/v0.1/spec.md#eventid
	EventID string `json:"eventID"`
	// EventTime is an optional property
	// https://github.com/cloudevents/spec/blob/v0.1/spec.md#eventtime
	EventTime *time.Time `json:"eventTime,omitempty"`
	// SchemaURL is an optional property
	// https://github.com/cloudevents/spec/blob/v0.1/spec.md#schemaurl
	SchemaURL string `json:"schemaURL,omitempty"`
	// ContentType is an optional property
	// https://github.com/cloudevents/spec/blob/v0.1/spec.md#contenttype
	ContentType string `json:"contentType,omitempty"`
	// Extensions is an optional property
	// https://github.com/cloudevents/spec/blob/v0.1/spec.md#extensions
	Extensions map[string]interface{} `json:"extensions,omitempty"`
	// Data is an optional property
	// https://github.com/cloudevents/spec/blob/v0.1/spec.md#data-1
	Data interface{} `json:"data,omitempty"`
}

Event implements the the CloudEvents specification version 0.1 https://github.com/cloudevents/spec/blob/v0.1/spec.md

func (Event) CloudEventVersion

func (Event) CloudEventVersion() (version string)

CloudEventVersion returns the CloudEvents specification version supported by this implementation

func (*Event) FromHTTPRequest

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

FromHTTPRequest parses the http request and returns a CloudEvent. https://github.com/cloudevents/spec/blob/a12b6b618916c89bfa5595fc76732f07f89219b5/http-transport-binding.md

func (*Event) Get

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

Get implements a generic getter method

func (*Event) MarshalJSON

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

MarshalJSON implements the JSON Marshaler interface.

func (Event) Properties

func (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(property string, value interface{})

Set sets the arbitrary property of event.

func (*Event) ToHTTPRequest

func (e *Event) ToHTTPRequest(req *http.Request, format HTTPFormat) error

ToHTTPRequest takes a pointer to existing http.Request struct and a binding format, and injects the event into to the struct using a format specified in CloudEvents HTTP transport binding. https://github.com/cloudevents/spec/blob/a12b6b618916c89bfa5595fc76732f07f89219b5/http-transport-binding.md

func (*Event) Validate

func (e *Event) Validate() error

Validate returns an error if the event is not correct according to the spec.

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"
)

Jump to

Keyboard shortcuts

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