ConditionalFilter
Verifies that a specified condition is met. If the condition is met, the request is dispatched to a delegate Filter. Otherwise, the delegate Filter is skipped.
Use ConditionalFilter
to easily use or skip a Filter depending on whether a condition is met. To easily use or skip a set of Filters, use a ChainOfFilters
as the delegate Filter and define a set of Filters. For information, see "ChainOfFilters".
Usage
{ "type": "ConditionalFilter", "config": { "condition": runtime expression<boolean>, "delegate": filter reference } }
Properties
"condition"
: runtime expression<boolean>, requiredIf the expression evaluates to
true
, the request is dispatched to the delegate Filter. Otherwise the delegate Filter is skipped.See also Expressions.
"delegate"
: filter reference, requiredFilter to treat the request if the condition expression evaluates as
true
.Provide an inline Filter configuration object, or the name of a Filter object defined in the heap.
See also Filters.
Example
The following example tests whether a request finishes with .js
or .jpg
:
{ "type": "Chain", "config": { "filters": [{ "type": "ConditionalFilter", "config": { "condition": "${not matches ((request.uri.path, '.js$') or (request.uri.path, '.jpg$'))}", "delegate": "mySingleSignOnFilter" } }], "handler": "ReverseProxyHandler" } }
If the request is to access a .js file or .jpg file, it skips the delegate SingleSignOnFilter filter declared in the heap, and passes straight to the ReverseProxyHandler.
If the request is to access another type of resource, it must pass through the delegate SingleSignOnFilter for authentication with AM before it can pass to the ReverseProxyHandler.