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.S3Event) (events.S3Event, error) {
	fmt.Printf("TEST\n \n")
	for _, record := range eh.Records {
		s3 := record.S3
		log.Printf("\nRECORDS:- %d", unsafe.Sizeof(record))
		log.Printf("\nEventName:= %s ", record.EventName)
		log.Printf("\nEventSource:- %s ", record.EventSource)
		log.Printf("\nEventVersion:- %s ", record.EventVersion)
		log.Printf("\nSourceIPAddress:- %s", record.RequestParameters.SourceIPAddress)
		log.Printf("\nBucketName:- %s \nObjectKey:- %s \n", s3.Bucket.Name, s3.Object.Key)
	}
	S3event := events.S3Event{Records: eh.Records}
	return S3event, nil
}
func main() {
	fmt.Println("going to call")
	runtime.Start(index.WrapHandler(handleRequest))
}
