Skip to content

Instantly share code, notes, and snippets.

@secretshardul
Last active February 12, 2020 05:12
Show Gist options
  • Save secretshardul/3497268b07cb3a96e5f5015c18f5af34 to your computer and use it in GitHub Desktop.
Save secretshardul/3497268b07cb3a96e5f5015c18f5af34 to your computer and use it in GitHub Desktop.
Lambda integration to parse x-www-form-urlencoded. The handler returns back the event as it is.
var qs = require('querystring')
exports.handler = async (event) => {
return event
};
{
"data": {
#foreach( $token in $input.path('$').split('&') )
#set( $keyVal = $token.split('=') )
#set( $keyValSize = $keyVal.size() )
#if( $keyValSize >= 1 )
#set( $key = $util.urlDecode($keyVal[0]) )
#if( $keyValSize >= 2 )
#set( $val = $util.urlDecode($keyVal[1]) )
#else
#set( $val = '' )
#end
"$key": "$val"#if($foreach.hasNext),#end
#end
#end
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment