go-micro: github.com/micro/go-micro/api/handler/cloudevents Index | Files

package cloudevents

import "github.com/micro/go-micro/api/handler/cloudevents"

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

Index

Package Files

cloudevents.go event.go

Constants

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

var (
    Handler = "cloudevents"
)

func NewHandler Uses

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

type Event Uses

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 Uses

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 Uses

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

New return new instance of Event.

func (*Event) Validate Uses

func (e *Event) Validate() error

Validate Event struct

type HTTPRequestData Uses

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.

Package cloudevents imports 15 packages (graph). Updated 2020-02-07. Refresh now. Tools for package owners.