AWSLambdaFunction.EntryPoint
1.0.1
dotnet add package AWSLambdaFunction.EntryPoint --version 1.0.1
NuGet\Install-Package AWSLambdaFunction.EntryPoint -Version 1.0.1
<PackageReference Include="AWSLambdaFunction.EntryPoint" Version="1.0.1" />
paket add AWSLambdaFunction.EntryPoint --version 1.0.1
#r "nuget: AWSLambdaFunction.EntryPoint, 1.0.1"
// 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 aHandler
property, which is a function that takes a request of typeTRequest
and anILambdaContext
, and returns a response of typeTResponse
. - Annotate Your Class with
LambdaEntryPointAttribute
: Specify the request and response types for your Lambda function by annotating your class with theLambdaEntryPointAttribute
.
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 | Versions 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. |
-
net8.0
- Amazon.Lambda.RuntimeSupport (>= 1.10.0)
- Amazon.Lambda.Serialization.Json (>= 2.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
- rename `LambdaFunctionAttribute` to `LambdaEntryPointAttribute`