Siemens.AspNet.Lambda.Sdk.Contracts
0.1.0-alpha.76
Prefix Reserved
dotnet add package Siemens.AspNet.Lambda.Sdk.Contracts --version 0.1.0-alpha.76
NuGet\Install-Package Siemens.AspNet.Lambda.Sdk.Contracts -Version 0.1.0-alpha.76
<PackageReference Include="Siemens.AspNet.Lambda.Sdk.Contracts" Version="0.1.0-alpha.76" />
<PackageVersion Include="Siemens.AspNet.Lambda.Sdk.Contracts" Version="0.1.0-alpha.76" />
<PackageReference Include="Siemens.AspNet.Lambda.Sdk.Contracts" />
paket add Siemens.AspNet.Lambda.Sdk.Contracts --version 0.1.0-alpha.76
#r "nuget: Siemens.AspNet.Lambda.Sdk.Contracts, 0.1.0-alpha.76"
#addin nuget:?package=Siemens.AspNet.Lambda.Sdk.Contracts&version=0.1.0-alpha.76&prerelease
#tool nuget:?package=Siemens.AspNet.Lambda.Sdk.Contracts&version=0.1.0-alpha.76&prerelease
Siemens.AspNet.Lambda.Sdk.Contracts
The Siemens.AspNet.Lambda.Sdk.Contracts
NuGet package provides core abstractions—interfaces, delegates, and base classes—essential for implementing AWS Lambda functions using the Siemens Lambda SDK. This contract library enables consistent, maintainable, and testable Lambda implementations.
📖 Overview
This package defines interfaces and delegates crucial for middleware-based pipeline handling and function execution in AWS Lambda environments.
✅ Key Abstractions
📐 Lambda Function Handlers
IFunctionHandler<TRequest>
IFunctionHandler<TRequest, TResponse>
🔗 Middleware Interfaces
ILambdaMiddleware<TRequest>
ILambdaMiddleware<TRequest, TResponse>
🚦 Pipeline Executors
ILambdaPipelineExecutor<TRequest>
ILambdaPipelineExecutor<TRequest, TResponse>
🔀 Delegates for Request Handling
LambdaRequestDelegate<TRequest>
LambdaRequestDelegate<TRequest, TResponse>
📌 Structured Error Logging
SpecificErrorLogHandler
📦 Installation
Using the .NET CLI
dotnet add package Siemens.AspNet.Lambda.Sdk.Contracts
🚀 Example Implementations
Implementing a simple Lambda function without response
public class MyFunction : FunctionBase<SQSEvent>
{
public override Task HandleAsync(SQSEvent request, ILambdaContext context)
{
// Your Lambda handling logic here
}
}
Implementing a simple Lambda function with request and response
public class Function : FunctionBase<CognitoPostConfirmationEvent, CognitoPostConfirmationEvent>
{
public override Task<CognitoPostConfirmationEvent> HandleAsync(CognitoPostConfirmationEvent request,
ILambdaContext context)
{
// Your Lambda handling logic here
}
}
Implementing a Lambda function with custom handler and dependency injection
Function:
public class Function : FunctionHandlerBase<Startup, CognitoPostConfirmationEvent, CognitoPostConfirmationEvent>
{
}
Startup:
public sealed class Startup : LambdaStartup
{
protected override void ConfigureServices(IServiceCollection services,
IConfiguration configuration)
{
base.ConfigureServices(services, configuration);
services.AddFunctionHandler();
}
}
FunctionHandler:
internal static class AddFunctionHandlerExtension
{
internal static void AddFunctionHandler(this IServiceCollection services)
{
services.AddSingletonIfNotExists<IFunctionHandler<CognitoPostConfirmationEvent, CognitoPostConfirmationEvent>, FunctionHandler>();
}
}
internal sealed class FunctionHandler(IMyService service,
IJsonSerializer jsonSerializer) : IFunctionHandler<CognitoPostConfirmationEvent, CognitoPostConfirmationEvent>
{
public Task<CognitoPostConfirmationEvent> HandleAsync(CognitoPostConfirmationEvent request,
ILambdaContext context)
{
// Your custom logic here
}
}
Lambda Middleware Pipeline
Leverage middleware for clean and maintainable request handling. Sample middleware for error logging: (This middleware is already included in the SDK and active !)
internal static class AddErrorLogRequestMiddlewareExtension
{
internal static void AddErrorLogRequestMiddleware(this IServiceCollection services)
{
services.AddErrorLoggingStrategyForLambda();
services.AddSingleton(typeof(ILambdaMiddleware<>), typeof(ErrorLogRequestMiddleware<>));
}
}
internal sealed class ErrorLogRequestMiddleware<TRequest>(IErrorLoggingStrategyForLambda errorLoggingStrategy) : ILambdaMiddleware<TRequest>
{
public async Task InvokeAsync(TRequest request,
ILambdaContext context,
LambdaRequestDelegate<TRequest> requestDelegate)
{
try
{
await requestDelegate(request, context).ConfigureAwait(false);
}
catch (Exception e)
{
await errorLoggingStrategy.HandleAsync(context, e).ConfigureAwait(false);
throw;
}
}
}
📌 Usage & Best Practices
- Use provided interfaces to structure Lambda functions clearly.
- Middleware helps implement cross-cutting concerns (logging, validation, error handling).
- Implement custom pipeline executors for advanced control over middleware execution flow.
📚 Documentation
Detailed documentation and examples are included in the source repository and will be published online soon.
📢 Contributing
Contributions and feedback are highly appreciated! Feel free to create issues or submit pull requests.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net9.0
- Amazon.Lambda.AspNetCoreServer.Hosting (>= 1.8.0)
- Extensions.Pack (>= 6.0.6)
- Siemens.AspNet.ErrorHandling.Contracts (>= 5.0.3)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Siemens.AspNet.Lambda.Sdk.Contracts:
Package | Downloads |
---|---|
Siemens.AspNet.Lambda.Sdk
The Siemens.AspNet.Lambda.Sdk NuGet package simplifies and accelerates the development of AWS Lambda functions using ASP.NET-inspired middleware pipelines, structured exception handling, and pre-configured startup patterns. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.1.0-alpha.76 | 25 | 5/3/2025 |
0.1.0-alpha.75 | 52 | 5/2/2025 |
0.1.0-alpha.74 | 59 | 5/2/2025 |