我在C#中使用了与Lambda的API网关非代理集成。我想知道如何打印和访问触发它的“ API网关事件”。
我可以使用'APIGatewayProxyRequest'类通过代理整合来做到这一点。 需要一个用于非代理集成的类。
using System.Threading.Tasks;
using Amazon.Lambda.APIGatewayEvents;
using Amazon.Lambda.Core;
using Newtonsoft.Json;
// Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class.
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))]
namespace AWSLambda17
{
public class Function
{
/// <summary>
/// A simple function that takes a string and does a ToUpper
/// </summary>
/// <param name="input"></param>
/// <param name="context"></param>
/// <returns></returns>
public Object FunctionHandler(APIGatewayProxyRequest input, ILambdaContext context)
{
Console.WriteLine(JsonConvert.SerializeObject(input));// Printing the event received
var response = new APIGatewayProxyResponse
{
StatusCode =200,
Body = {},
Headers = new Dictionary<string, string>
{
{ "Content-Type", "application/json" },
{ "Access-Control-Allow-Origin", "*" }
}
};
return (response);
}
}
}
需要具有非代理整合的代码。