-
Notifications
You must be signed in to change notification settings - Fork 488
/
Copy pathGreeter.cs
47 lines (42 loc) · 1.55 KB
/
Greeter.cs
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Threading.Tasks;
using Amazon.Lambda.Annotations;
using Amazon.Lambda.Annotations.APIGateway;
using Amazon.Lambda.APIGatewayEvents;
using Amazon.Lambda.Core;
namespace TestServerlessApp
{
public class Greeter
{
[LambdaFunction(ResourceName = "GreeterSayHello", MemorySize = 1024, PackageType = LambdaPackageType.Image)]
[HttpApi(LambdaHttpMethod.Get, "/Greeter/SayHello", Version = HttpApiVersion.V1)]
public void SayHello([FromQuery(Name = "names")]IEnumerable<string> firstNames, APIGatewayProxyRequest request, ILambdaContext context)
{
context.Logger.LogLine($"Request {JsonSerializer.Serialize(request)}");
if (firstNames == null)
{
return;
}
foreach (var firstName in firstNames)
{
Console.WriteLine($"Hello {firstName}");
}
}
[LambdaFunction(ResourceName = "GreeterSayHelloAsync", Timeout = 50, PackageType = LambdaPackageType.Image)]
[HttpApi(LambdaHttpMethod.Get, "/Greeter/SayHelloAsync", Version = HttpApiVersion.V1)]
public async Task SayHelloAsync([FromHeader(Name = "names")]IEnumerable<string> firstNames)
{
if (firstNames == null)
{
return;
}
foreach (var firstName in firstNames)
{
Console.WriteLine($"Hello {firstName}");
}
await Task.CompletedTask;
}
}
}