与AWS Lamdba c#的API网关集成(非代理集成)

时间:2019-01-04 09:41:25

标签: c#

我在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);
        }
    }

}

需要具有非代理整合的代码。

0 个答案:

没有答案