Skip to content

Conversation

@normj
Copy link
Member

@normj normj commented Jan 29, 2026

Issue #, if available:
#1574

Description of changes:
The Amazon.Lambda.AspNetCoreServer was 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.Hosting which 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 the Amazon.Lambda.AspNetCoreServer. This made a really simple to enable because all they have to do is call builder.Services.AddAWSLambdaHosting(LambdaEventSource.RestApi) in the Program.cs and if we detect the project is running in Lambda we do all of the setup work.

The shortcoming of Amazon.Lambda.AspNetCoreServer.Hosting is 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 HostOptions that can be passed into AddAWSLambdaHosting that provides Actions and other properties that will be connected to the subclass allowing users to take advantage of all of the extensions points available in Amazon.Lambda.AspNetCoreServer.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

…oints available in Amazon.Lambda.AspNetCoreServer
Copy link

Copilot AI left a 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 HostingOptions class with properties for configuring response encoding, exception handling, and marshalling callbacks
  • Integrated HostingOptions into 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.

normj and others added 9 commits January 29, 2026 12:40
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants