Permalink
Fetching contributors…
Cannot retrieve contributors at this time
57 lines (53 sloc) 2.47 KB
#*
Provide an automatic pass through template that transforms all inputs
into the JSON payload sent to a golang function. The default behavior passes the 'body'
key as raw string.
See
https://forums.aws.amazon.com/thread.jspa?threadID=220274&tstart=0
http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html
*#
{
"method": "$context.httpMethod",
"body" : "$input.path('$')",
"headers": {
#foreach($param in $input.params().header.keySet())
"$param": "$util.escapeJavaScript($input.params().header.get($param))" #if($foreach.hasNext),#end
#end
},
"queryParams": {
#foreach($param in $input.params().querystring.keySet())
"$param": "$util.escapeJavaScript($input.params().querystring.get($param))" #if($foreach.hasNext),#end
#end
},
"pathParams": {
#foreach($param in $input.params().path.keySet())
"$param": "$util.escapeJavaScript($input.params().path.get($param))" #if($foreach.hasNext),#end
#end
},
"context" : {
"apiId" : "$util.escapeJavaScript($context.apiId)",
"method" : "$util.escapeJavaScript($context.httpMethod)",
"requestId" : "$util.escapeJavaScript($context.requestId)",
"resourceId" : "$util.escapeJavaScript($context.resourceId)",
"resourcePath" : "$util.escapeJavaScript($context.resourcePath)",
"stage" : "$util.escapeJavaScript($context.stage)",
"identity" : {
"accountId" : "$util.escapeJavaScript($context.identity.accountId)",
"apiKey" : "$util.escapeJavaScript($context.identity.apiKey)",
"caller" : "$util.escapeJavaScript($context.identity.caller)",
"cognitoAuthenticationProvider" : "$util.escapeJavaScript($context.identity.cognitoAuthenticationProvider)",
"cognitoAuthenticationType" : "$util.escapeJavaScript($context.identity.cognitoAuthenticationType)",
"cognitoIdentityId" : "$util.escapeJavaScript($context.identity.cognitoIdentityId)",
"cognitoIdentityPoolId" : "$util.escapeJavaScript($context.identity.cognitoIdentityPoolId)",
"sourceIp" : "$util.escapeJavaScript($context.identity.sourceIp)",
"user" : "$util.escapeJavaScript($context.identity.user)",
"userAgent" : "$util.escapeJavaScript($context.identity.userAgent)",
"userArn" : "$util.escapeJavaScript($context.identity.userArn)"
}
},
"authorizer": {
#foreach($param in $context.authorizer.keySet())
"$param": "$util.escapeJavaScript($context.authorizer.get($param))" #if($foreach.hasNext),#end
#end
}
}