-
Notifications
You must be signed in to change notification settings - Fork 501
Expand file tree
/
Copy pathAuthorizerFunction_RestApiAuthorize_Generated.g.cs
More file actions
59 lines (50 loc) · 2.65 KB
/
Copy pathAuthorizerFunction_RestApiAuthorize_Generated.g.cs
File metadata and controls
59 lines (50 loc) · 2.65 KB
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
// <auto-generated/>
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Amazon.Lambda.Core;
namespace TestCustomAuthorizerApp
{
public class AuthorizerFunction_RestApiAuthorize_Generated
{
private readonly AuthorizerFunction authorizerFunction;
private readonly Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer serializer;
/// <summary>
/// Default constructor. This constructor is used by Lambda to construct the instance. When invoked in a Lambda environment
/// the AWS credentials will come from the IAM role associated with the function and the AWS region will be set to the
/// region the Lambda function is executed in.
/// </summary>
public AuthorizerFunction_RestApiAuthorize_Generated()
{
SetExecutionEnvironment();
authorizerFunction = new AuthorizerFunction();
serializer = new Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer();
}
/// <summary>
/// The generated Lambda function handler for <see cref="RestApiAuthorize(Amazon.Lambda.APIGatewayEvents.APIGatewayCustomAuthorizerRequest, Amazon.Lambda.Core.ILambdaContext)"/>
/// </summary>
/// <param name="__request__">The API Gateway authorizer request object that will be processed by the Lambda function handler.</param>
/// <param name="__context__">The ILambdaContext that provides methods for logging and describing the Lambda environment.</param>
/// <returns>Result of the Lambda function execution</returns>
public Amazon.Lambda.APIGatewayEvents.APIGatewayCustomAuthorizerResponse RestApiAuthorize(Amazon.Lambda.APIGatewayEvents.APIGatewayCustomAuthorizerRequest __request__, Amazon.Lambda.Core.ILambdaContext __context__)
{
var response = authorizerFunction.RestApiAuthorize(__request__, __context__);
return response;
}
private static void SetExecutionEnvironment()
{
const string envName = "AWS_EXECUTION_ENV";
var envValue = new StringBuilder();
// If there is an existing execution environment variable add the annotations package as a suffix.
if(!string.IsNullOrEmpty(Environment.GetEnvironmentVariable(envName)))
{
envValue.Append($"{Environment.GetEnvironmentVariable(envName)}_");
}
envValue.Append("lib/amazon-lambda-annotations#{ANNOTATIONS_ASSEMBLY_VERSION}");
Environment.SetEnvironmentVariable(envName, envValue.ToString());
}
}
}