Skip to content

Instantly share code, notes, and snippets.

@pahud
Last active December 2, 2022 21:17
Show Gist options
  • Save pahud/b5e8c0fc0ada43eb54d4 to your computer and use it in GitHub Desktop.
Save pahud/b5e8c0fc0ada43eb54d4 to your computer and use it in GitHub Desktop.
API Gateway mapping template(VTL) to convert request object into JSON object for Lambda
{
"body" : $input.json('$'),
"headers": {
#foreach($header in $input.params().header.keySet())
"$header": "$util.escapeJavaScript($input.params().header.get($header))" #if($foreach.hasNext),#end
#end
},
"method": "$context.httpMethod",
"params": {
#foreach($param in $input.params().path.keySet())
"$param": "$util.escapeJavaScript($input.params().path.get($param))" #if($foreach.hasNext),#end
#end
},
"query": {
#foreach($queryParam in $input.params().querystring.keySet())
"$queryParam": "$util.escapeJavaScript($input.params().querystring.get($queryParam))" #if($foreach.hasNext),#end
#end
}
}
@pahud
Copy link
Author

pahud commented Feb 27, 2016

output like this

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment