Documentation ¶
Overview ¶
Package s3 provides types to support unmarshalling generic `event *json.RawMessage` types into S3 specific event structures. Sparta-based S3 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 spartaS3.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 { switch eachRecord.EventName { case "ObjectCreated:Put": {...} default : {...} } } }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bucket ¶
type Bucket struct { Name string `json:"name"` Arn string `json:"arn"` OwnerIdentity EventOwnerIdentity `json:"ownerIdentity"` }
Bucket event data
type EventOwnerIdentity ¶
type EventOwnerIdentity struct {
PrincpalID string `json:"principalId"`
}
EventOwnerIdentity event data
type EventRecord ¶
type EventRecord struct { Region string `json:"awsRegion"` EventName string `json:"eventName"` EventTime string `json:"eventTime"` EventSource string `json:"eventSource"` EventVersion string `json:"eventVersion"` S3 S3 `json:"s3"` }
EventRecord event data
Click to show internal directories.
Click to hide internal directories.