diff --git a/handler.go b/handler.go index aaa6193..4136c19 100644 --- a/handler.go +++ b/handler.go @@ -4,10 +4,8 @@ import ( "context" "log/slog" "os" - "testing" "github.com/aws/aws-lambda-go/lambdacontext" - "github.com/stretchr/testify/assert" ) type LambdaHandler struct { @@ -25,7 +23,12 @@ func NewAWSLambdaHandler(ctx context.Context, opts *slog.HandlerOptions) slog.Ha } // Retrieve AWS Request ID and lambda function arn - lc, _ := lambdacontext.FromContext(ctx) + lc, found := lambdacontext.FromContext(ctx) + + if !found { + return slog.NewJSONHandler(os.Stdout, opts) + } + requestID := lc.AwsRequestID arn := lc.InvokedFunctionArn @@ -52,4 +55,4 @@ func getLogLevel() slog.Leveler { } return l -} \ No newline at end of file +}