-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLambdaEntryPoint.cs
More file actions
33 lines (26 loc) · 828 Bytes
/
Copy pathLambdaEntryPoint.cs
File metadata and controls
33 lines (26 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using System.IO;
using System.Threading.Tasks;
namespace Serverless.Getting.Started
{
public class LambdaEntryPoint
{
public Task<Stream> FunctionHandlerAsync(Stream inputStream)
{
var response = new LambdaResponse(){
body = "Hello, I came from AWS Lambda"
};
return Task.FromResult(ConvertToStream(response));
}
private Stream ConvertToStream(LambdaResponse response)
{
var serializer = new Newtonsoft.Json.JsonSerializer();
var memStream = new MemoryStream();
var writer = new StreamWriter(memStream);
serializer.Serialize(writer, response);
writer.Flush();
memStream.Position = 0;
return memStream;
}
}
}