Add extension point support in Amazon.Lambda.AspNetCoreServer.Hosting#2267
Open
Add extension point support in Amazon.Lambda.AspNetCoreServer.Hosting#2267
Conversation
…oints available in Amazon.Lambda.AspNetCoreServer
There was a problem hiding this comment.
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
GarrettBeatty
approved these changes
Jan 29, 2026
…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>
muhammad-othman
approved these changes
Feb 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.