SwitchFilter — divert exchange to other handler
Conditionally diverts the exchange to another handler. If a
condition evaluates to true, then the
exchange is dispatched to the associated handler with no
further processing by the switch filter.
{
"name": string,
"type": "SwitchFilter",
"config": {
"onRequest": [
{
"condition": expression,
"handler": string,
}, ...
],
"onResponse": [
{
"condition": expression,
"handler": string,
}, ...
]
}
}"onRequest": array of objects,
optionalConditions to test (and handler to dispatch to, if
true) before the exchange is handled.
"onResponse": array of objects,
optionalConditions to test (and handler to dispatch to, if
true) after the exchange is handled.
"condition": expression,
optionalCondition to evaluate to determine if exchange should be dispatched to handler. Default: unconditional dispatch to handler.
"handler": string, requiredThe name of the handler heap object to dispatch to if condition
yields true.
This example intercepts the response if it is equal to 200 and executes the LoginRequestHandler. This filter might be used in a login flow where the request for the login page must go through to the target, but the response should be intercepted in order to send the login form to the application. This is typical for scenarios where there is a hidden value or cookie returned in the login page which must be sent in the login form:
{
"name": "SwitchFilter",
"type": "SwitchFilter",
"config": {
"onResponse": [
{
"condition": "${exchange.response.status == 200}",
"handler": "LoginRequestHandler"
}
]
}
}