Policies support Handlebars, a templating engine for resolving the configurable parameters of the policy and
implementing semantic logic, such as conditionals. This is the preferred method of using user inputs in the policies.
Each policy parameter defined in a YAML Configuration file will be available as a HandleBars variable for resolving the
final policy configuration.
|
|
Handlebars is an extension of Mustache, which was used in earlier versions of Mule policies.
|
Depending on the parameter type defined in the YAML, the variable will be of a different HandleBars type.
String, Expression, Radio, Int, and Boolean are primitive types in HandleBars.
The primitive types can be referenced from the policy template using curly brackets:
{{{myproperty}}}
Keyvalues are complex types in HandleBars. Complex types have inner properties, and those can be referenced as follows:
{{{keyvalue.key}}}
{{{keyvalue.value}}}
There are some properties that are available to use in policies without being defined in the YAML Configuration file:
-
policyId id of the policy, useful for logging or naming a policy
-
isWsdlEndpoint indicates whether the API where the policy is being applied is a WSDL API.
When an Identity Management is defined for the organization where the API is being applied, then the following
properties are also available:
identityManagementTokenUrl introspection endpoint of the identity management.
identityManagementClientId client Id for authenticating to the introspection endpoint.
identityManagementClientSecret client secret for authenticating to the introspection endpoint.