Last active
April 6, 2016 16:14
-
-
Save Opus1no2/149545583a41b79ec50cbd81837fb267 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if ($context.httpMethod == "POST") | |
#set($rawAPIData = $input.path('$')) | |
#elseif ($context.httpMethod == "GET") | |
#set($rawAPIData = $input.params().querystring) | |
#set($rawAPIData = $rawAPIData.toString()) | |
#set($rawAPIDataLength = $rawAPIData.length() - 1) | |
#set($rawAPIData = $rawAPIData.substring(1, $rawAPIDataLength)) | |
#set($rawAPIData = $rawAPIData.replace(", ", "&")) | |
#else | |
#set($rawAPIData = "") | |
#end | |
#set($countAmpersands = $rawAPIData.length() - $rawAPIData.replace("&", "").length()) | |
#if ($countAmpersands == 0) | |
#set($rawPostData = $rawAPIData + "&") | |
#end | |
#set($tokenisedAmpersand = $rawAPIData.split("&")) | |
#set($tokenisedEquals = []) | |
#foreach( $kvPair in $tokenisedAmpersand ) | |
#set($countEquals = $kvPair.length() - $kvPair.replace("=", "").length()) | |
#if ($countEquals == 1) | |
#set($kvTokenised = $kvPair.split("=")) | |
#if ($kvTokenised[0].length() > 0) | |
## we found a valid key value pair. add it to the list. | |
#set($devNull = $tokenisedEquals.add($kvPair)) | |
#end | |
#end | |
#end | |
{ | |
#foreach( $kvPair in $tokenisedEquals ) | |
#set($kvTokenised = $kvPair.split("=")) | |
"$util.urlDecode($kvTokenised[0])" : #if($kvTokenised.size() > 1 && $kvTokenised[1].length() > 0)"$util.urlDecode($kvTokenised[1])"#{else}"null"#end#if( $foreach.hasNext ),#end | |
#end | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment