aws / aws-lambda-dotnet

Libraries, samples and tools to help .NET Core developers develop AWS Lambda functions.
Apache License 2.0
1.58k stars 477 forks source link

Adding ASP.NET Core IServer hosting for Websocket APIs #1801

Closed wiowou closed 2 months ago

wiowou commented 2 months ago

Issue #, if available:

Description of changes: API Gateway Websocket APIs currently error out when using this library to handle requests since the RequestContext.Http object is null. This change allows this library to be used with Websocket APIs by setting the Http.Path to the RouteKey and the Http.Method fixed as POST. This approach requires the user to reference the same lambda for the RouteKeys which they want handled by the lambda server.

The changes to the APIGatewayHttpApiV2ProxyFunction class is minimal and adds a APIGatewayWebsocketApiV2ProxyFunction class and corresponding changes to the Amazon.Lambda.AspNetCoreServer.Hosting project to provide for a Websocket option.

All tests that were passing in the current master branch are passing in the PR.

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

wiowou commented 2 months ago

I plan to add tests, shortly.

wiowou commented 2 months ago

I think I should have derived from APIGatewayProxyFunction and not APIGatewayHttpApiV2ProxyFunction. I will rework this.

wiowou commented 2 months ago

I will open a different PR.