Forum Discussion
Robert_47833
Nov 14, 2011Altostratus
how to use switch to match datagroup
1:there is a datagroup:cjj
how to use switch to match this group
switch -glob [HTTP::path] {
"cjj" xxxx ???
2:
switch -glob [HTTP::path] { "*jpg" - "*bmp" - ...
hooleylist
Nov 14, 2011Cirrostratus
Jucao,
What are you actually trying to do? Do you want to see if an HTTP path ends with a set of extensions?
If so, you could either use a switch statement or the class command with the ends_with operator and a datagroup. There isn't a logical way to combine a switch statement and a class lookup in one operation. From Joe's testing, a datagroup is probably more efficient than a switch statement if you consider matches in the beginning, middle and end of the list of strings:
http://devcentral.f5.com/Tutorials/TechTips/tabid/63/articleType/ArticleView/articleId/1086424/Comparing-iRule-Control-Statements.aspx
However, when using a small list of strings (<100) the results are close enough that it probably makes sense to choose a switch statement if it's easier for you to manage the strings inline within the iRule instead of in a datagroup.
Aaron
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