Documentation
¶
Overview ¶
Package envelope normalizes inbound trigger event payloads. A Decoder understands one wire format (raw JSON, CloudEvents, Pub/Sub push, SNS, Azure Event Grid, Slack Events API) and produces a provider-agnostic Event.
Index ¶
- Constants
- func ApplySelectors(event *Event, headers http.Header, typeFrom, idFrom FieldSelector) error
- func AzureEventGridValidationCode(event *Event) (string, error)
- func DecodeJSON(body []byte) (any, error)
- func SlackChallenge(event *Event) (string, error)
- func ValidateSelector(selector FieldSelector) error
- type AzureEventGrid
- type CloudEvents
- type Decoder
- type Event
- type FieldSelector
- type PubSubPush
- type Raw
- type SlackEvents
Constants ¶
const AzureEventGridValidationEventType = "Microsoft.EventGrid.SubscriptionValidationEvent"
AzureEventGridValidationEventType identifies the Event Grid subscription validation handshake event.
const SlackURLVerificationType = "url_verification"
SlackEventType for URL verification handshake requests.
Variables ¶
This section is empty.
Functions ¶
func ApplySelectors ¶
func ApplySelectors(event *Event, headers http.Header, typeFrom, idFrom FieldSelector) error
ApplySelectors overrides the event ID and type from the configured selectors. Header selectors only apply when the header is present; payload selectors must match exactly one nonempty string.
func AzureEventGridValidationCode ¶
AzureEventGridValidationCode extracts the subscription validation code from a validation handshake event. It returns "" for regular events.
func DecodeJSON ¶
DecodeJSON decodes a JSON document preserving number precision.
func SlackChallenge ¶
SlackChallenge extracts the url_verification challenge from a decoded Slack event. It returns "" for regular event callbacks.
func ValidateSelector ¶
func ValidateSelector(selector FieldSelector) error
ValidateSelector rejects selectors that set both sources or use an invalid payload path.
Types ¶
type AzureEventGrid ¶
type AzureEventGrid struct{}
AzureEventGrid decodes an Azure Event Grid delivery containing exactly one event.
type CloudEvents ¶
type CloudEvents struct{}
CloudEvents decodes a structured-mode CloudEvents 1.0 envelope. The envelope's own ID becomes the dedupe ID even when selectors override the event ID.
type Decoder ¶
Decoder decodes one wire format into a normalized Event. A nil Event with a nil error means the request was valid but carries no event to persist (for example an SNS subscription confirmation).
type Event ¶
type Event struct {
ID string
DedupeID string
Source string
Type string
OccurredAt *time.Time
Payload json.RawMessage
ContentType string
}
Event is a normalized inbound event, independent of the wire format it arrived in.
type FieldSelector ¶
type FieldSelector struct {
Header string `json:"header,omitempty"`
Payload string `json:"payload,omitempty"`
}
FieldSelector extracts an event field from a request header or a JSONPath expression evaluated against the event payload.
type PubSubPush ¶
type PubSubPush struct{}
PubSubPush decodes a Google Pub/Sub push delivery envelope.
type Raw ¶
type Raw struct{}
Raw decodes an unwrapped JSON event. The event ID defaults to the body digest so retried deliveries dedupe; selectors may override it.
type SlackEvents ¶
type SlackEvents struct{}
SlackEvents decodes a Slack Events API envelope: either a url_verification handshake or an event_callback wrapping the inner event.