package main

import (
	"context"
	"fmt"
	"github.com/abhi9560/GoLayer"
	"github.com/aws/aws-lambda-go/events"
	runtime "github.com/aws/aws-lambda-go/lambda"
	"log"
	"unsafe"
)

func handleRequest(ctx context.Context, eh events.SNSEvent) (events.SNSEvent, error) {
	for _, message := range eh.Records {
		snsRecord := message.SNS
		log.Printf("\nRECORDS:- %d", unsafe.Sizeof(message))
		log.Printf("\nEventSource:- %s ", message.EventSource)
		log.Printf("\nEventVersion:- %s ", message.EventVersion)
		log.Printf("\nTimestamp: %s ", snsRecord.Timestamp)
		log.Printf("\nMessage:- %s ", snsRecord.Message)
		log.Printf("\nSignature:- %s \nSigningCertURL:- %s \n", snsRecord.Signature, snsRecord.SigningCertURL)
	}
	SNSevent := events.SNSEvent{Records: eh.Records}
	return SNSevent, nil
}

func main() {
	fmt.Println("going to call")
	runtime.Start(index.WrapHandler(handleRequest))
}
