A policy template to fork and use as a quick starter.
This policy will compare X-Template-Policy header value with its configuration errorKey field, if both values are equal, then the policy will interrupt the request with a failure execution error.
Implements TemplatePolicy#onRequest(HttpExecutionContext context) and TemplatePolicy#onResponse(HttpExecutionContext context) to develop your own policy.
|
Note
|
This policy is designed to work with at least APIM 4.0.0. |
To develop a policy working with AM or a v2 definition of an API in APIM, please follow the v3 example implementation of the policy.
You can configure the policy with the following options:
| Property | Required | Description | Type | Default |
|---|---|---|---|---|
errorKey |
X |
Policy will fail if header |
string |
"failure" |
Example configuration:
{
"configuration": {
"errorKey": "value-to-fail-the-policy"
}
}With the provided default implementation, policy will fail if header X-Template-Policy value is equal to configured errorKey value.
| Phase | Code | Error template key | Description |
|---|---|---|---|
REQUEST |
|
POLICY_TEMPLATE_ERROR_KEY |
An error occurs during request |
RESPONSE |
|
POLICY_TEMPLATE_ERROR_KEY |
An error occurs during response |