Forum Discussion
Michael_Benzing
Nimbostratus
Jan 26, 2014Syntax of "switch" statement
I have seen some switch statements in our F5 rules that seem to be using "else" instead of the "default" keyword to catch all unmatched searches. Based on documentation, it would seem to me that the ...
nitass_89166
Noctilucent
Jan 26, 2014e.g.
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm rule quux
ltm rule quux {
when HTTP_REQUEST {
switch -glob [HTTP::uri] {
somesvc { log local0. "[HTTP::uri] - somesvc"; return }
/mysvc* { log local0. "[HTTP::uri] - /mysvc*"; return }
/ { log local0. "[HTTP::uri] - /"; return }
else { log local0. "[HTTP::uri] - else"; return }
}
log local0. "[HTTP::uri] - not match"
}
}
[root@ve11a:Active:In Sync] config tail -f /var/log/ltm
Jan 26 09:17:16 ve11a info tmm1[11129]: Rule /Common/quux : /mysvc/something - /mysvc*
Jan 26 09:17:18 ve11a info tmm[11129]: Rule /Common/quux : /somethingelse - not match
- Michael_BenzingJan 26, 2014
Nimbostratus
Thanks for the test results! My initial thoughts were that this was being treated as a literal and not a keyword.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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