Skip to content

Instantly share code, notes, and snippets.

@jakelodwick
Created March 12, 2016 17:13
Show Gist options
  • Save jakelodwick/d291fdcd42e47b807cca to your computer and use it in GitHub Desktop.
Save jakelodwick/d291fdcd42e47b807cca to your computer and use it in GitHub Desktop.
AWS API Gateway - Integration Request - Mapping Template
#*
Via <http://kennbrodhagen.net/2015/12/06/how-to-create-a-request-object-for-your-lambda-event-from-api-gateway/>.
This mapping template formats most information that API Gateway receives, for easy use in a Lambda function (or whatever).
Not sure why the same effect isn't achieved with the "Input passthrough" option!
*#
{
"method": "$context.httpMethod",
"body" : $input.json('$'),
"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
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment