Forum Discussion
lunitic_56137
Aug 15, 2012Nimbostratus
Switch statement not working
I have an 11.2 deployment that is using this iRule. The issue is that the Switch statement will not work.
"when HTTP_REQUEST {
switch -glob [HTTP::uri] {
"/uri1" -
...
Aug 15, 2012
Can you provide any more details? It's hard to figure out from here without knowing the test cases you are passing in and what results you are seeing (or not).
The one thing that sticks out is that I'm not sure if you can call the "node" command and then call the "pool" command. If the URI is "/uri3" and it also is returned from the matchclass command, you could have both commands executing. That may work, but I'm not sure.
I'd start with some logging. You can throw in "log local0. 'blah blah blah'" before each of the other commands and look in the /var/log/ltm file to see if the logic is working.
If you don't want the if/else logic processed if one of the previous "switch" matches passes, then you can include it in a default case for the switch
switch -glob [HTTP::uri] {
"/uri1" -
"/uri2" {
HTTP::redirect ...
}
"/uri3" -
"/uri4" {
node 1.1.1.1 80
}
default {
if { [matchclass ... } {
pool J2EE_pool
} else {
HTTP::redirect http://other.site.com
}
}
}
Not sure if that will help or not, but hopefully lead you in the right direction.
-Joe
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