@@ -6,45 +6,69 @@ const awsArnRegExs = require('../../../utils/arnRegularExpressions');
6
6
7
7
const LAMBDA_PROXY_REQUEST_TEMPLATE = `
8
8
#define( $loop )
9
- {
9
+ {
10
10
#foreach($key in $map.keySet())
11
- #set( $k = $util.escapeJavaScript($key) )
12
- #set( $v = $util.escapeJavaScript($map.get($key)).replaceAll("\\\\'", "'") )
13
- "$k":
11
+ #set( $k = $util.escapeJavaScript($key) )
12
+ #set( $v = $util.escapeJavaScript($map.get($key)).replaceAll("\\\\'", "'") )
13
+ "$k":
14
+ #if ("$v" == "")
15
+ null
16
+ #else
14
17
"$v"
15
- #if( $foreach.hasNext ) , #end
18
+ #end
19
+ #if( $foreach.hasNext ) , #end
16
20
#end
17
- }
21
+ }
18
22
#end
19
23
#define( $smInput )
20
24
{
21
- "body": $body,
22
- "httpMethod": "$context.httpMethod",
23
- "path": "$context.path",
24
25
"resource": "$context.resourcePath",
26
+ "path": "$context.path",
27
+ "httpMethod": "$context.httpMethod",
25
28
#set( $map = $input.params().header )
26
29
"headers": $loop,
30
+
31
+ #if ($input.params().querystring.size() == 0)
32
+ "queryStringParameters": null,
33
+ #else
27
34
#set( $map = $input.params().querystring )
28
35
"queryStringParameters": $loop,
36
+ #end
37
+
38
+ #if ($input.params().path.size() == 0)
39
+ "pathParameters": null,
40
+ #else
29
41
#set( $map = $input.params().path )
30
42
"pathParameters": $loop,
43
+ #end
44
+
45
+ #if ($stageVariables.size() == 0)
46
+ "stageVariables": null,
47
+ #else
48
+ #set( $map = $stageVariables )
49
+ "stageVariables": $loop,
50
+ #end
51
+
31
52
"requestContext": {
32
- "accountId": "\${AccountId}",
33
53
"resourceId": "$context.resourceId",
34
- "stage": "$context.stage",
35
- "requestId": "$context.requestId",
54
+ "resourcePath": "$context.resourcePath",
55
+ "httpMethod": "$context.httpMethod",
56
+ "extendedRequestId": "$context.extendedRequestId",
36
57
"requestTime": "$context.requestTime",
58
+ "path": "$context.path",
59
+ "accountId": "\${AccountId}",
60
+ "protocol": "$context.protocol",
61
+ "stage": "$context.stage",
62
+ "domainPrefix": "$context.domainPrefix",
37
63
"requestTimeEpoch": "$context.requestTimeEpoch",
64
+ "requestId": "$context.requestId",
38
65
#set( $map = $context.identity )
39
66
"identity": $loop,
40
- "path": "$context.path",
41
- "resourcePath": "$context.resourcePath",
42
- "httpMethod": "$context.httpMethod",
43
- "protocol": "$context.protocol",
67
+ "domainName": "$context.domainName",
44
68
"apiId": "$context.apiId"
45
69
},
46
- #set( $map = $stageVariables )
47
- "stageVariables ": $loop
70
+ "body": "$util.escapeJavaScript("$body")",
71
+ "isBase64Encoded ": false
48
72
}
49
73
#end
50
74
{
@@ -54,7 +78,7 @@ const LAMBDA_PROXY_REQUEST_TEMPLATE = `
54
78
}` ;
55
79
56
80
const LAMBDA_PROXY_JSON_REQUEST_TEMPLATE = `
57
- #set( $body = $input.json('$') )
81
+ #set( $body = $input.body )
58
82
${ LAMBDA_PROXY_REQUEST_TEMPLATE } ` ;
59
83
60
84
const LAMBDA_PROXY_FORM_URL_ENCODED_REQUEST_TEMPLATE = `
0 commit comments