I am creating a request mapping template for AWS API gateway. In that template I want to customize the request params based on certain conditions and apply operators.
#foreach($header in $input.params().header.keySet())
#if($header=="id")#set($idVal =
$util.escapeJavaScript($input.params().header.get($header)))
#if($idVal.matches("^[0-9a-f]{4}-[0-9A-Z]{3}$"))
"$header":"$idVal"
#else
#set($random = UUID.randomUUID())
"$header":"$random"
#end
#else
For example, in the above template based on if condition I want to generate randomUUID and add to the header. But when I test, the id value is set to empty string.
How can I use packages and java functions support in velocity template mapping api gateway? Also, please share any reference to wellformed template, it would be really useful to learn more.