-
Notifications
You must be signed in to change notification settings - Fork 488
/
Copy pathCustomizeResponseExamples.cs
70 lines (64 loc) · 3.25 KB
/
CustomizeResponseExamples.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using Amazon.Lambda.Annotations;
using Amazon.Lambda.Annotations.APIGateway;
using Amazon.Lambda.Core;
using System.Threading.Tasks;
namespace TestServerlessApp
{
public class CustomizeResponseExamples
{
[LambdaFunction(PackageType = LambdaPackageType.Image)]
[RestApi(LambdaHttpMethod.Get, "/okresponsewithheader/{x}")]
public IHttpResult OkResponseWithHeader(int x, ILambdaContext context)
{
return HttpResults.Ok("All Good")
.AddHeader("Single-Header", "Value")
.AddHeader("Multi-Header", "Foo")
.AddHeader("Multi-Header", "Bar");
}
[LambdaFunction(PackageType = LambdaPackageType.Image)]
[RestApi(LambdaHttpMethod.Get, "/okresponsewithheaderasync/{x}")]
public Task<IHttpResult> OkResponseWithHeaderAsync(int x, ILambdaContext context)
{
return Task.FromResult(HttpResults.Ok("All Good")
.AddHeader("Single-Header", "Value")
.AddHeader("Multi-Header", "Foo")
.AddHeader("Multi-Header", "Bar"));
}
[LambdaFunction(PackageType = LambdaPackageType.Image)]
[HttpApi(LambdaHttpMethod.Get, "/notfoundwithheaderv2/{x}")]
public IHttpResult NotFoundResponseWithHeaderV2(int x, ILambdaContext context)
{
return HttpResults.NotFound("Not Found")
.AddHeader("Single-Header", "Value")
.AddHeader("Multi-Header", "Foo")
.AddHeader("Multi-Header", "Bar");
}
[LambdaFunction(PackageType = LambdaPackageType.Image)]
[HttpApi(LambdaHttpMethod.Get, "/notfoundwithheaderv2async/{x}")]
public Task<IHttpResult> NotFoundResponseWithHeaderV2Async(int x, ILambdaContext context)
{
return Task.FromResult(HttpResults.NotFound("Not Found")
.AddHeader("Single-Header", "Value")
.AddHeader("Multi-Header", "Foo")
.AddHeader("Multi-Header", "Bar"));
}
[LambdaFunction(PackageType = LambdaPackageType.Image)]
[HttpApi(LambdaHttpMethod.Get, "/notfoundwithheaderv1/{x}", Version = HttpApiVersion.V1)]
public IHttpResult NotFoundResponseWithHeaderV1(int x, ILambdaContext context)
{
return HttpResults.NotFound("Not Found")
.AddHeader("Single-Header", "Value")
.AddHeader("Multi-Header", "Foo")
.AddHeader("Multi-Header", "Bar");
}
[LambdaFunction(PackageType = LambdaPackageType.Image)]
[HttpApi(LambdaHttpMethod.Get, "/notfoundwithheaderv1async/{x}", Version = HttpApiVersion.V1)]
public Task<IHttpResult> NotFoundResponseWithHeaderV1Async(int x, ILambdaContext context)
{
return Task.FromResult(HttpResults.NotFound("Not Found")
.AddHeader("Single-Header", "Value")
.AddHeader("Multi-Header", "Foo")
.AddHeader("Multi-Header", "Bar"));
}
}
}