cloudevents

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package cloudevents provides a cloudevents handler publishing the event using the go-micro/client

Index

Constants

View Source
const (
	// TransformationVersion is indicative of the revision of how Event Gateway transforms a request into CloudEvents format.
	TransformationVersion = "0.1"

	// CloudEventsVersion currently supported by Event Gateway
	CloudEventsVersion = "0.1"
)

Variables

View Source
var (
	Handler = "cloudevents"
)

Functions

func NewHandler

func NewHandler(opts ...handler.Option) handler.Handler

Types

type Event

type Event struct {
	EventType          string                 `json:"eventType" validate:"required"`
	EventTypeVersion   string                 `json:"eventTypeVersion,omitempty"`
	CloudEventsVersion string                 `json:"cloudEventsVersion" validate:"required"`
	Source             string                 `json:"source" validate:"uri,required"`
	EventID            string                 `json:"eventID" validate:"required"`
	EventTime          *time.Time             `json:"eventTime,omitempty"`
	SchemaURL          string                 `json:"schemaURL,omitempty"`
	Extensions         map[string]interface{} `json:"extensions,omitempty"`
	ContentType        string                 `json:"contentType,omitempty"`
	Data               interface{}            `json:"data"`
}

Event is a default event structure. All data that passes through the Event Gateway is formatted to a format defined CloudEvents v0.1 spec.

func FromRequest

func FromRequest(r *http.Request) (*Event, error)

FromRequest takes an HTTP request and returns an Event along with path. Most of the implementation is based on https://github.com/cloudevents/spec/blob/master/http-transport-binding.md. This function also supports legacy mode where event type is sent in Event header.

func New

func New(eventType string, mimeType string, payload interface{}) *Event

New return new instance of Event.

func (*Event) Validate

func (e *Event) Validate() error

Validate Event struct

type HTTPRequestData

type HTTPRequestData struct {
	Headers map[string]string   `json:"headers"`
	Query   map[string][]string `json:"query"`
	Body    interface{}         `json:"body"`
	Host    string              `json:"host"`
	Path    string              `json:"path"`
	Method  string              `json:"method"`
	Params  map[string]string   `json:"params"`
}

HTTPRequestData is a event schema used for sending events to HTTP subscriptions.

Jump to

Keyboard shortcuts

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