Skip to content

Instantly share code, notes, and snippets.

@venkatperi
Created August 25, 2015 02:59
Show Gist options
  • Save venkatperi/a59864e2bea30a6db5c8 to your computer and use it in GitHub Desktop.
Save venkatperi/a59864e2bea30a6db5c8 to your computer and use it in GitHub Desktop.
General purpose request template for AWS Api Gateway methods. Use with /{resource}
#set($root = $input.path('$'))
#set($res = {"method":"$context.httpMethod", "resource":"$input.params('resource')", "requestId":"$context.requestId" })
#set( $optional = ["Authorization", "X-MyApp-Api-Token"])
#foreach ($x in $optional)
#if ($input.params($x).length() > 0)
#set( $res[$x.toLowerCase()] = $input.params($x))
#end
#end
{
#set($map=$res)
#foreach($k in $map.keySet())
"$k":"$map.get($k)"#if ($foreach.hasNext),#end
#end,
"__data" : $input.json('$')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment