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, refer to
ChainOfFilters.
Usage
{
"name": string,
"type": "ConditionalFilter",
"config": {
"condition": runtime condition<boolean>,
"delegate": Filter reference
}
}
Properties
"condition"
: runtime condition<boolean>, required-
A condition. If the condition’s expression evaluates to
true
, PingGateway dispatches the request to the delegate filter. Otherwise, PingGateway skips the delegate filter. "delegate"
: Filter reference, required-
A filter to treat the request when the condition expression evaluates as
true
.
Example
The following example tests whether a request finishes with .js
or .jpg
:
{
"type": "Chain",
"config": {
"filters": [{
"type": "ConditionalFilter",
"config": {
"condition": "${not (find(request.uri.path, '.js$') or find(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.