sns

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2018 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package sns provides types to support unmarshalling generic `event *json.RawMessage` types into SNS specific event structures. Sparta-based SNS event listeners can unmarshall the RawMesssage into source-specific data. Example:

func s3EventListener(event *json.RawMessage,
                      context *sparta.LambdaContext,
                      w http.ResponseWriter,
                      logger *logrus.Logger) {
  var lambdaEvent spartaSNS.Event
  err := json.Unmarshal([]byte(*event), &lambdaEvent)
  if err != nil {
    logger.Error("Failed to unmarshal event data: ", err.Error())
    http.Error(w, err.Error(), http.StatusInternalServerError)
  }
  for _, eachRecord := range lambdaEvent.Records {
    logger.Info("Message subject: ", eachRecord.Subject)
  }
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Records []EventRecord
}

Event data

type EventRecord

type EventRecord struct {
	EventSource          string `json:"EventSource"`
	EventVersion         string `json:"EventVersion"`
	EventSubscriptionArn string `json:"EventSubscriptionArn"`
	Sns                  Sns    `json:"Sns"`
}

EventRecord event data

type MessageAttributeValues

type MessageAttributeValues struct {
	Type  string `json:"Type"`
	Value string `json:"Value"`
}

MessageAttributeValues type/value data for the parent key

type Sns

type Sns struct {
	Type              string `json:"Type"`
	MessageID         string `json:"MessageId"`
	TopicArn          string `json:"TopicArn"`
	Subject           string `json:"Subject"`
	Message           string `json:"Message"`
	Timestamp         string `json:"Timestamp"`
	SignatureVersion  string `json:"SignatureVersion"`
	Signature         string `json:"Signature"`
	SigningCertURL    string `json:"SigningCertUrl"`
	UnsubscribeURL    string `json:"UnsubscribeUrl"`
	MessageAttributes map[string]MessageAttributeValues
}

Sns event information

Jump to

Keyboard shortcuts

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