When writing aws lambda on dotnet 3.1, we can get parameters as following;
public async Task<APIGatewayProxyResponse> FunctionHandler(APIGatewayProxyRequest request, ILambdaContext context)
{
...
}
But dotnet 6 minimal api, I can not get this paramter like this;
app.MapGet("/students/{name}", async (APIGatewayProxyRequest request)=>
{
..
}
Does anybody know how to get this parameter on minimal api?
CodePudding user response:
To use Minimal API in .NET Core with AWS Lambda. Follow below steps.
1. Select AWS Serverless Application from project templates.
2. Use ASP.NET Core Minimal API blueprint.
This project uses NuGet package Amazon.Lambda.AspNetCoreServer
, that contains a Lambda function (similar to what you have shown in code snippet).
public async Task<APIGatewayProxyResponse> FunctionHandler(APIGatewayProxyRequest request, ILambdaContext context)
{
...
// 1. this lambda function receives requests from API Gateway
// 2. redirects request to ASP.NET Core controller, process it
// 3. returns the response back to API Gateway
...
}
This lambda function is used to translate requests from the API Gateway into the ASP.NET Core framework and then the responses from ASP.NET Core back to API Gateway.