Forum Discussion
Kalyan_Reddy_Da
Nimbostratus
Jul 20, 2010Irule with if-elseif to change to Switch-glob
Irule with if-elseif to change to Switch-glob
Please help me if anyone know how to change this if-else-if irule to switch-glob.
when HTTP_REQUEST {
if {([HTTP::cookie "TestCookie"] ne "") && ([HTTP::header "TestHeader"] eq "")} {
Execute some statements
}
elseif { [HTTP::cookie "ABCD"] contains "testvaluel" } {
Execute some statements
}
elseif {[HTTP::header "DEF"] ne "" } {
Execute some statements
}
elseif { ([HTTP::uri] starts_with "/abc/def/") } {
Execute some statements
}
}
- hoolio
Cirrostratus
Hi Kalyan, - Kalyan_Reddy_Da
Nimbostratus
Thank you Aaron for the quick reply. Appreciate your help. - hoolio
Cirrostratus
Catch can only ever return 0 or 1 based on whether the command it's executing returns an error or not, so I don't think there is any advantage to using switch. But if you wanted to, you could do this:set pool_name p_test_$TEST switch [catch { pool $pool_name } ] { 0 { No error, so the pool was already assigned and you don't have to do anything more } 1 { Error, so do something else Execute some commands } }
set pool_name p_test_$TEST if { [catch { pool $pool_name } ] } { Error assigning pool $pool_name, so do something else }
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects