Forum Discussion
iRule Order Evaluation
I am changing the iRule to send all /api requests to a new pool if a flag is set, as I want to be able to simply flip a flag on or off to redirect traffic appropriately. I don't want to take the /api out of the datagroup as I want the ability to use a variable flag to flip the new pool on or off depending on what is going on.
My concern is, in the following if/else/then block will the first line evaluate true or the second? In other words, does the TCL language read through the entire block before it takes action? Or does it take action based on the first condition that matches? In both lines (the /api and $myapiflag) as well as the class match $myluri, rule is true because /api exists in both the datagroup. I want the first line to be evaluated only if the uri starts with api and the flag is set.
when HTTP_REQUEST {
set myhost [HTTP::host]
set myuri [HTTP::uri]
set myluri [string tolower $myuri]
set myapiflag 0
if { $myluri starts_with "/api" && $myapiflag } {
pool api.pool.com_8080
} elseif { [class match $myluri starts_with clients_noredirect_class]} {
pool clients.pool.com_80
} elseif { $myhost equals "" } {
if { [class match $myluri starts_with clients_noredirect_class] } {
pool app.pool.com_80
}
} else {
HTTP::redirect ""
}
}
- nitass
Employee
not sure if i understand question correctly. anyway, pool api.pool.com_8080 will be selected only if $myluri starts_with "/api" AND $myapiflag is set (not equal to 0). - Wes_98712
Nimbostratus
Nitass that is exactly what I am asking. If both lines evaluate as true, which one is selected? The first or the second? - Wes, for the first successful test, that code block will be executed and then processing will halt for anything else in the elseif/else tests.
- Wes_98712
Nimbostratus
Thanks Joe that's what I needed to know.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com