/
offline-default.req.vm
44 lines (44 loc) · 1.36 KB
/
offline-default.req.vm
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
#define( $loop )
{
#foreach($key in $map.keySet())
"$util.escapeJavaScript($key)":
"$util.escapeJavaScript($map.get($key))"
#if( $foreach.hasNext ) , #end
#end
}
#end
{
"body": $input.json("$"),
"method": "$context.httpMethod",
"principalId": "$context.authorizer.principalId",
"stage": "$context.stage",
"cognitoPoolClaims" : {
"sub": "$context.authorizer.claims.sub"
},
#set( $map = $context.authorizer )
## see https://github.com/serverless/serverless/issues/4374
"enhancedAuthContext": {
#foreach($key in $map.keySet())
## The claims are not part of the enhancedAuthContext in serverless and should be excluded.
## However it is more practical to set this property to null as defined in
## https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html#context-variable-reference
#if($key == "claims")
"$key": null
#else
"$key": "$util.escapeJavaScript($map.get($key))"
#end
#if($foreach.hasNext),#end
#end
},
#set( $map = $input.params().header )
"headers": $loop,
#set( $map = $input.params().querystring )
"query": $loop,
#set( $map = $input.params().path )
"path": $loop,
#set( $map = $context.identity )
"identity": $loop,
#set( $map = $stageVariables )
"stageVariables": $loop,
"requestPath": "$context.resourcePath"
}