|
5 | 5 | [](https://sonarcloud.io/summary/new_code?id=j-d-ha_minimal-lambda) |
6 | 6 | [](LICENSE) |
7 | 7 |
|
8 | | -**ASP.NET Core-style patterns for AWS Lambda** – Build Lambda functions (for any trigger) using the same clean, declarative patterns as ASP.NET Core Minimal APIs. |
| 8 | +**Lambda-first hosting with Minimal API-inspired patterns** – Familiar .NET ergonomics with handlers, DI, and middleware, purpose-built for AWS Lambda triggers. |
9 | 9 |
|
10 | 10 | > 📚 **[View Full Documentation](https://j-d-ha.github.io/minimal-lambda/)** |
11 | 11 |
|
12 | 12 | ## Overview |
13 | 13 |
|
14 | | -**If you know ASP.NET Core Minimal APIs, you already know MinimalLambda.** |
| 14 | +MinimalLambda brings the clean, declarative style of ASP.NET Core Minimal APIs to AWS Lambda while staying grounded in Lambda’s execution model. Use the same mental model (builder, DI, middleware, handler mapping) while leaning on Lambda-specific features like strongly-typed envelopes, lifecycle hooks, scoped invocations, and source generation. |
15 | 15 |
|
16 | | -MinimalLambda brings the clean, declarative coding style of ASP.NET Core Minimal APIs to AWS Lambda – for **any trigger type** (SQS, SNS, API Gateway, Kinesis, S3, EventBridge, and more): |
| 16 | +- **Familiar builder flow**: `LambdaApplication.CreateBuilder()` → `Build()` → `RunAsync()` |
| 17 | +- **.NET DI you already use**: `builder.Services.AddScoped<IMyService, MyService>()` with Lambda-safe lifetimes |
| 18 | +- **Handler mapping, Lambda edition**: `lambda.MapHandler(...)` instead of crafting raw handlers |
| 19 | +- **Middleware for cross-cutting concerns**: `lambda.UseMiddleware(...)` to wrap your pipeline |
| 20 | +- **Lambda-first runtime**: Lifecycle hooks, cancellation token management, and strongly typed envelope models for event triggers |
17 | 21 |
|
18 | | -- **Same builder pattern**: `LambdaApplication.CreateBuilder()` → `Build()` → `RunAsync()` |
19 | | -- **Same dependency injection**: `builder.Services.AddScoped<IMyService, MyService>()` |
20 | | -- **Same handler mapping**: `lambda.MapHandler(...)` just like `app.MapGet(...)` |
21 | | -- **Same middleware pipeline**: `lambda.Use(...)` for cross-cutting concerns |
22 | | -- **Same foundation**: Built on `Microsoft.Extensions.Hosting` like ASP.NET Core |
23 | | - |
24 | | -Instead of writing boilerplate Lambda handlers, you get familiar .NET patterns with automatic dependency injection, proper scoped lifetimes, middleware support, and compile-time code generation for zero reflection overhead. |
| 22 | +Instead of writing boilerplate Lambda handlers, you keep familiar .NET patterns while the framework handles event envelopes, dependency injection, scoped lifetimes, middleware, and compile-time code generation for zero reflection overhead. |
25 | 23 |
|
26 | 24 | ## Key Features |
27 | 25 |
|
28 | 26 | - **Minimal API Pattern** – Map handlers with `lambda.MapHandler(...)` just like `app.MapGet()` in ASP.NET Core – clean, declarative, and intuitive |
29 | 27 | - **Dependency Injection** – Constructor and parameter injection using `Microsoft.Extensions.DependencyInjection` with proper scoped lifetimes per invocation |
30 | 28 | - **Middleware Pipeline** – Familiar `Use()` pattern for cross-cutting concerns like logging, validation, and error handling |
31 | 29 | - **Source Generated** – Compile-time code generation for zero reflection overhead and optimal performance |
32 | | -- **AOT Ready** – Native AOT compilation support for sub-100ms cold starts |
| 30 | +- **AOT Ready** – Native AOT compilation support for fast cold starts |
33 | 31 | - **Built-in Observability** – OpenTelemetry integration for distributed tracing and metrics |
34 | 32 | - **Type-Safe Envelopes** – Strongly-typed event wrappers for SQS, SNS, API Gateway, Kinesis, and more |
35 | 33 | - **Minimal Runtime Overhead** – Lightweight abstraction layer built on the same foundation as ASP.NET Core |
36 | 34 |
|
37 | | -## From ASP.NET Core to Lambda |
38 | | - |
39 | | -If you're familiar with ASP.NET Core Minimal APIs, the transition to MinimalLambda is seamless: |
40 | | - |
41 | | -| ASP.NET Core Minimal API | MinimalLambda | |
42 | | -|---|---| |
43 | | -| `WebApplication.CreateBuilder()` | `LambdaApplication.CreateBuilder()` | |
44 | | -| `app.MapGet("/hello", ...)` | `lambda.MapHandler(...)` | |
45 | | -| `builder.Services.AddScoped<T>()` | `builder.Services.AddScoped<T>()` | |
46 | | -| `app.UseMiddleware<T>()` | `lambda.UseMiddleware<T>()` | |
47 | | -| `app.RunAsync()` | `lambda.RunAsync()` | |
48 | | -| `HttpContext` dependency injection | `ILambdaContext` dependency injection | |
49 | | -| Route parameters | `[Event]` attribute for event binding | |
50 | | - |
51 | | -The patterns are intentionally identical – if you know one, you know the other. |
52 | | - |
53 | 35 | ## Packages |
54 | 36 |
|
55 | 37 | The framework is divided into multiple NuGet packages: |
|
0 commit comments