AWSLambdaFunction.EntryPoint 1.0.1

dotnet add package AWSLambdaFunction.EntryPoint --version 1.0.1                
NuGet\Install-Package AWSLambdaFunction.EntryPoint -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AWSLambdaFunction.EntryPoint" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AWSLambdaFunction.EntryPoint --version 1.0.1                
#r "nuget: AWSLambdaFunction.EntryPoint, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AWSLambdaFunction.EntryPoint as a Cake Addin
#addin nuget:?package=AWSLambdaFunction.EntryPoint&version=1.0.1

// Install AWSLambdaFunction.EntryPoint as a Cake Tool
#tool nuget:?package=AWSLambdaFunction.EntryPoint&version=1.0.1                

AWSLambdaFunction.EntryPoint

The AWSLambdaFunction.EntryPoint NuGet package simplifies the creation of AWS Lambda functions in .NET 8.0 by allowing developers to abstract away the boilerplate Main method and focus on the business logic. This package introduces a declarative approach to define Lambda entry points using attributes and interfaces.

Defining Your Lambda Function

  • Implement the ILambdaHandler<TRequest, TResponse> Interface: This interface requires you to define a Handler property, which is a function that takes a request of type TRequest and an ILambdaContext, and returns a response of type TResponse.
  • Annotate Your Class with LambdaEntryPointAttribute: Specify the request and response types for your Lambda function by annotating your class with the LambdaEntryPointAttribute.

Example

Here's a simple example of a Lambda function that accepts a string request and returns a JSON object:

using Amazon.Lambda.Core;
using Newtonsoft.Json.Linq;
using AWSLambdaFunction.EntryPoint;
using AWSLambdaFunction.EntryPoint.Attributes;

[LambdaEntryPoint(typeof(string), typeof(JToken))]
public class LambdaFunction : ILambdaHandler<string, JToken>
{
    public Func<string, ILambdaContext, JToken> Handler => Run;

    private JToken Run(string message, ILambdaContext context)
    {
        var data = new JObject
        {
            ["message"] = message
        };

        context.Logger.LogLine($"Received message: {message}");
        return data;
    }
}
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 148 2/20/2024
1.0.0 113 2/20/2024

- rename `LambdaFunctionAttribute` to `LambdaEntryPointAttribute`