-
Notifications
You must be signed in to change notification settings - Fork 497
Add extension point support in Amazon.Lambda.AspNetCoreServer.Hosting #2267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
…oints available in Amazon.Lambda.AspNetCoreServer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds extension point support to Amazon.Lambda.AspNetCoreServer.Hosting, enabling users to customize the Lambda-ASP.NET Core bridging behavior without needing to subclass internal types. This addresses issue #1574, which requested support for binary response types like image/webp in ASP.NET Core 6+ using the Minimal API hosting pattern.
Changes:
- Added
HostingOptionsclass with properties for configuring response encoding, exception handling, and marshalling callbacks - Integrated
HostingOptionsinto the three MinimalApi implementations (APIGatewayHttpApiV2, APIGatewayRestApi, ApplicationLoadBalancer) - Added comprehensive test coverage for the new functionality
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| Libraries/src/Amazon.Lambda.AspNetCoreServer.Hosting/HostingOptions.cs | New options class exposing extension points for binary response encoding and marshalling callbacks with detailed XML documentation |
| Libraries/src/Amazon.Lambda.AspNetCoreServer.Hosting/ServiceCollectionExtensions.cs | Registers HostingOptions as a singleton in the DI container |
| Libraries/src/Amazon.Lambda.AspNetCoreServer.Hosting/Internal/LambdaRuntimeSupportServer.cs | Integrates HostingOptions into all three MinimalApi implementations, applying configurations and invoking callbacks |
| Libraries/src/Amazon.Lambda.AspNetCoreServer.Hosting/Amazon.Lambda.AspNetCoreServer.Hosting.csproj | Adds InternalsVisibleTo for test assembly access |
| Libraries/test/Amazon.Lambda.AspNetCoreServer.Hosting.Tests/HostingOptionsTests.cs | Comprehensive unit tests for HostingOptions functionality (589 lines) |
| Libraries/test/Amazon.Lambda.AspNetCoreServer.Hosting.Tests/ServiceCollectionExtensionsTests.cs | Integration tests for service registration (184 lines) |
| Libraries/test/Amazon.Lambda.AspNetCoreServer.Hosting.Tests/ApplicationLoadBalancerMinimalApiTests.cs | Tests for ApplicationLoadBalancer MinimalApi configuration and callbacks (900 lines) |
| Libraries/test/Amazon.Lambda.AspNetCoreServer.Hosting.Tests/APIGatewayRestApiMinimalApiTests.cs | Tests for RestApi MinimalApi configuration and callbacks (899 lines) |
| Libraries/test/Amazon.Lambda.AspNetCoreServer.Hosting.Tests/APIGatewayHttpApiV2MinimalApiTests.cs | Tests for HttpApiV2 MinimalApi configuration and callbacks (898 lines) |
| Libraries/test/Amazon.Lambda.AspNetCoreServer.Hosting.Tests/Amazon.Lambda.AspNetCoreServer.Hosting.Tests.csproj | Adds project reference to TestUtilities |
| Libraries/test/Amazon.Lambda.AspNetCoreServer.Hosting.Tests/AddAWSLambdaBeforeSnapshotRequestTests.cs | Increases test timeout from 500ms to 5000ms |
| .autover/changes/12b85f20-8478-422b-a662-2f4aff4b6509.json | Version bump metadata (minor version change) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
.../test/Amazon.Lambda.AspNetCoreServer.Hosting.Tests/AddAWSLambdaBeforeSnapshotRequestTests.cs
Outdated
Show resolved
Hide resolved
Libraries/src/Amazon.Lambda.AspNetCoreServer.Hosting/HostingOptions.cs
Outdated
Show resolved
Hide resolved
...ries/test/Amazon.Lambda.AspNetCoreServer.Hosting.Tests/APIGatewayHttpApiV2MinimalApiTests.cs
Outdated
Show resolved
Hide resolved
...ries/test/Amazon.Lambda.AspNetCoreServer.Hosting.Tests/APIGatewayHttpApiV2MinimalApiTests.cs
Outdated
Show resolved
Hide resolved
...ries/test/Amazon.Lambda.AspNetCoreServer.Hosting.Tests/APIGatewayHttpApiV2MinimalApiTests.cs
Outdated
Show resolved
Hide resolved
Libraries/test/Amazon.Lambda.AspNetCoreServer.Hosting.Tests/APIGatewayRestApiMinimalApiTests.cs
Outdated
Show resolved
Hide resolved
Libraries/test/Amazon.Lambda.AspNetCoreServer.Hosting.Tests/APIGatewayRestApiMinimalApiTests.cs
Outdated
Show resolved
Hide resolved
.../test/Amazon.Lambda.AspNetCoreServer.Hosting.Tests/ApplicationLoadBalancerMinimalApiTests.cs
Outdated
Show resolved
Hide resolved
.../test/Amazon.Lambda.AspNetCoreServer.Hosting.Tests/ApplicationLoadBalancerMinimalApiTests.cs
Outdated
Show resolved
Hide resolved
.../test/Amazon.Lambda.AspNetCoreServer.Hosting.Tests/ApplicationLoadBalancerMinimalApiTests.cs
Outdated
Show resolved
Hide resolved
…IGatewayHttpApiV2MinimalApiTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…IGatewayHttpApiV2MinimalApiTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…stingOptionsTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…IGatewayRestApiMinimalApiTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…plicationLoadBalancerMinimalApiTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…plicationLoadBalancerMinimalApiTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…IGatewayRestApiMinimalApiTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…stingOptionsTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Issue #, if available:
#1574
Description of changes:
The
Amazon.Lambda.AspNetCoreServerwas the first package released to support bridging ASP.NET Core with Lambda. It worked by users subclasses some classes in the package that implement the function handler. Users could override some virtual methods on the base class to customize the conversion from Lambda to ASP.NET Core and back.When Minimal APIs became a thing we added
Amazon.Lambda.AspNetCoreServer.Hostingwhich takes care of bootstrapping both the Amazon.Lambda.RuntimeSupport because a Minimal API project is always an executable. As part of that bootstrapping it inserted it's precanned subclasses for theAmazon.Lambda.AspNetCoreServer. This made a really simple to enable because all they have to do is callbuilder.Services.AddAWSLambdaHosting(LambdaEventSource.RestApi)in theProgram.csand if we detect the project is running in Lambda we do all of the setup work.The shortcoming of
Amazon.Lambda.AspNetCoreServer.Hostingis sense you don't provide your own sub class you can override any of the virtual methods to customize the behavior.This issue address that by providing options on the
HostOptionsthat can be passed intoAddAWSLambdaHostingthat providesActionsand other properties that will be connected to the subclass allowing users to take advantage of all of the extensions points available inAmazon.Lambda.AspNetCoreServer.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.