-
Notifications
You must be signed in to change notification settings - Fork 499
Support API Gateway websocket api via LambdaServer #1804
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
25c0c33
Support API Gateway websocket api via LambdaServer
wiowou 1f5717a
Merge pull request #2229 from aws/dev
philasmar ad0ebab
update permissions (#2231) (#2232)
GarrettBeatty 1dbfbf2
Merge branch 'dev'
aws-sdk-dotnet-automation a4310dc
Merge branch 'dev'
aws-sdk-dotnet-automation 0548eb3
Dev (#2248)
GarrettBeatty 3f6de4a
Merge branch 'dev'
aws-sdk-dotnet-automation fd18ef2
Merge pull request #2258 from aws/dev
philasmar 6e7c60b
Merge branch 'dev'
aws-sdk-dotnet-automation 15145bf
Merge branch 'dev'
aws-sdk-dotnet-automation bc0c745
Merge branch 'dev'
aws-sdk-dotnet-automation 281133d
Merge branch 'dev'
aws-sdk-dotnet-automation e61e9a5
Merge branch 'dev'
aws-sdk-dotnet-automation 3af4abf
Merge branch 'dev'
aws-sdk-dotnet-automation c28fcfa
Merge branch 'dev'
aws-sdk-dotnet-automation f3cf8cc
Merge pull request #2296 from aws/dev
philasmar dc91547
Merge pull request #2307 from aws/dev
philasmar a5b74f6
Merge branch 'dev'
aws-sdk-dotnet-automation 52d0de4
Merge branch 'dev'
aws-sdk-dotnet-automation cb78042
Merge branch 'dev'
aws-sdk-dotnet-automation 64a47bb
Merge branch 'dev'
aws-sdk-dotnet-automation e9d0d74
Merge branch 'dev'
aws-sdk-dotnet-automation caea55b
Merge pull request #2334 from aws/dev
philasmar 5820339
Merge branch 'dev'
aws-sdk-dotnet-automation ffa4585
Merge branch 'dev'
aws-sdk-dotnet-automation 35b2e8f
Merge branch 'dev'
aws-sdk-dotnet-automation c63d743
Merge branch 'dev'
aws-sdk-dotnet-automation dfbb7ac
Merge branch 'dev'
aws-sdk-dotnet-automation 5de51e0
Merge branch 'dev'
aws-sdk-dotnet-automation 40cdd7f
pr fixes: api gateway websocket api
4c22317
fixed merge conflict. Logical changes remain
0fc8136
fix lambda runtime support server
5ad44ab
simplify calls
acd15d7
pr fixes: api gateway websocket api
89a6b33
Merge branch 'dev' into websocket
GarrettBeatty 26b9cd0
Fix websocket Hosting wiring and simplify MinimalApi
GarrettBeatty 05ae11c
Add autover change file for websocket support
GarrettBeatty File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
70 changes: 70 additions & 0 deletions
70
Libraries/src/Amazon.Lambda.AspNetCoreServer/APIGatewayWebsocketApiProxyFunction.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| using System; | ||
|
|
||
| using Microsoft.AspNetCore.Http; | ||
|
|
||
| using Amazon.Lambda.APIGatewayEvents; | ||
| using Amazon.Lambda.AspNetCoreServer.Internal; | ||
|
|
||
| namespace Amazon.Lambda.AspNetCoreServer | ||
| { | ||
| /// <summary> | ||
| /// Base class for ASP.NET Core Lambda functions that are getting request from API Gateway Websocket API V2 payload format. | ||
| /// | ||
| /// The http method is fixed as POST. Requests are handled using the RouteKey, so the same lambda should be referenced by multiple API Gateway routes for the ASP.NET Core IServer to successfully route requests. | ||
| /// </summary> | ||
| public abstract class APIGatewayWebsocketApiProxyFunction : APIGatewayProxyFunction | ||
| { | ||
| /// <summary> | ||
| /// Default constructor | ||
| /// </summary> | ||
| protected APIGatewayWebsocketApiProxyFunction() | ||
| : base() | ||
| { | ||
|
|
||
| } | ||
|
|
||
| /// <inheritdoc/> | ||
| /// <param name="startupMode">Configure when the ASP.NET Core framework will be initialized</param> | ||
| protected APIGatewayWebsocketApiProxyFunction(StartupMode startupMode) | ||
| : base(startupMode) | ||
| { | ||
|
|
||
| } | ||
|
|
||
| /// <summary> | ||
| /// Constructor used by Amazon.Lambda.AspNetCoreServer.Hosting to support ASP.NET Core projects using the Minimal API style. | ||
| /// </summary> | ||
| /// <param name="hostedServices"></param> | ||
| protected APIGatewayWebsocketApiProxyFunction(IServiceProvider hostedServices) | ||
| : base(hostedServices) | ||
| { | ||
| _hostServices = hostedServices; | ||
| } | ||
|
|
||
| /// <inheritdoc/> | ||
| /// <param name="apiGatewayRequest"></param> | ||
| /// <returns>string</returns> | ||
| protected override string ParseHttpPath(APIGatewayProxyRequest apiGatewayRequest) | ||
| { | ||
| var path = "/" + Utilities.DecodeResourcePath(apiGatewayRequest.RequestContext.RouteKey); | ||
| return path; | ||
| } | ||
|
|
||
| /// <inheritdoc/> | ||
| /// <param name="apiGatewayRequest"></param> | ||
| /// <returns>string</returns> | ||
| protected override string ParseHttpMethod(APIGatewayProxyRequest apiGatewayRequest) | ||
| { | ||
| return "POST"; | ||
| } | ||
|
|
||
| /// <inheritdoc/> | ||
| /// <returns>IHeaderDictionary</returns> | ||
| protected override IHeaderDictionary AddMissingRequestHeaders(APIGatewayProxyRequest apiGatewayRequest, IHeaderDictionary headers) | ||
| { | ||
| headers = base.AddMissingRequestHeaders(apiGatewayRequest, headers); | ||
| headers["Content-Type"] = "application/json"; | ||
|
wiowou marked this conversation as resolved.
Outdated
|
||
| return headers; | ||
| } | ||
| } | ||
| } | ||
40 changes: 40 additions & 0 deletions
40
...aries/src/Amazon.Lambda.AspNetCoreServer/APIGatewayWebsocketApiProxyFunction{TStartup}.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| using Microsoft.AspNetCore.Hosting; | ||
| using System.Diagnostics.CodeAnalysis; | ||
|
|
||
| namespace Amazon.Lambda.AspNetCoreServer | ||
| { | ||
| /// <summary> | ||
| /// APIGatewayWebsocketApiV2ProxyFunction is the base class that is implemented in a ASP.NET Core Web API. The derived class implements | ||
| /// the Init method similar to Main function in the ASP.NET Core and provides typed Startup. The function handler for | ||
| /// the Lambda function will point to this base class FunctionHandlerAsync method. | ||
| /// </summary> | ||
|
wiowou marked this conversation as resolved.
|
||
| /// <typeparam name ="TStartup">The type containing the startup methods for the application.</typeparam> | ||
| public abstract class APIGatewayWebsocketApiProxyFunction<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.PublicConstructors)] TStartup> : APIGatewayWebsocketApiProxyFunction where TStartup : class | ||
| { | ||
| /// <summary> | ||
| /// Default Constructor. The ASP.NET Core Framework will be initialized as part of the construction. | ||
| /// </summary> | ||
| protected APIGatewayWebsocketApiProxyFunction() | ||
| : base() | ||
| { | ||
|
|
||
| } | ||
|
|
||
|
|
||
| /// <summary> | ||
| /// | ||
| /// </summary> | ||
|
GarrettBeatty marked this conversation as resolved.
|
||
| /// <param name="startupMode">Configure when the ASP.NET Core framework will be initialized</param> | ||
| protected APIGatewayWebsocketApiProxyFunction(StartupMode startupMode) | ||
| : base(startupMode) | ||
| { | ||
|
|
||
| } | ||
|
|
||
| /// <inheritdoc/> | ||
| protected override void Init(IWebHostBuilder builder) | ||
| { | ||
| builder.UseStartup<TStartup>(); | ||
| } | ||
| } | ||
| } | ||
25 changes: 25 additions & 0 deletions
25
Libraries/test/Amazon.Lambda.AspNetCoreServer.Test/Amazon.Lambda.AspNetCoreServer.Test.sln
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| | ||
| Microsoft Visual Studio Solution File, Format Version 12.00 | ||
| # Visual Studio Version 17 | ||
| VisualStudioVersion = 17.5.002.0 | ||
| MinimumVisualStudioVersion = 10.0.40219.1 | ||
| Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Amazon.Lambda.AspNetCoreServer.Test", "Amazon.Lambda.AspNetCoreServer.Test.csproj", "{AE614E81-1148-41E0-9CA7-B1F3EB34B65E}" | ||
| EndProject | ||
| Global | ||
| GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
| Debug|Any CPU = Debug|Any CPU | ||
| Release|Any CPU = Release|Any CPU | ||
| EndGlobalSection | ||
| GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
| {AE614E81-1148-41E0-9CA7-B1F3EB34B65E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| {AE614E81-1148-41E0-9CA7-B1F3EB34B65E}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| {AE614E81-1148-41E0-9CA7-B1F3EB34B65E}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
| {AE614E81-1148-41E0-9CA7-B1F3EB34B65E}.Release|Any CPU.Build.0 = Release|Any CPU | ||
| EndGlobalSection | ||
| GlobalSection(SolutionProperties) = preSolution | ||
| HideSolutionNode = FALSE | ||
| EndGlobalSection | ||
| GlobalSection(ExtensibilityGlobals) = postSolution | ||
| SolutionGuid = {FDFB946B-997E-4736-A826-7461752C8DF4} | ||
| EndGlobalSection | ||
| EndGlobal |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.