Lambda Annotations API Routing #1616
Labels
annotations
feature-request
A feature should be added or improved.
p2
This is a standard priority issue
Describe the feature
With the release of the
[LambdaGlobalProperties]
attribute that can auto-generate thestatic Main()
method for non managed and native AOT runtimes this functionality could be extended to provide API routing capabilities. The API annotations on methods could be used as part of a switch statement for the inbound API event.Use Case
Running a simple web API on Lambda without needing to introduce the overhead of ASP.NET. Removes the need to set the
ANNOTATIONS_HANDLER
environment variable when running multiple API endpoints in the same Lambda function.Allows the use of an API Gateway
{proxy+}
route with all API request routing to the same Lambda function.Proposed Solution
The
GenerateMain
global properties attribute adds a switch statement based on an environment variable. Introduce a newApiRouting
Lambda Global Property that will generate thestatic Main
method. Include a switch statement that uses a combination of theHttpMethod
andPath
from the incoming API event to route to the correct method.Example of generated code:
Other Information
No response
Acknowledgements
AWS .NET SDK and/or Package version used
Amazon.Lambda.Annotations
Targeted .NET Platform
.NET 6, .NET 8
Operating System and version
All
The text was updated successfully, but these errors were encountered: