What it does
Describe one decision as ordered rules ("paths starting with /api go to api_pool, /login goes to login_pool, everything else to web_pool") and the tool writes it three ways:
- an
if/elseifchain, - a
switch(with-globwhen a rule needs it, and--before the value), - a
class matchlookup on data groups, with thetmshdefinitions of the data groups.
A test value then runs through each generated rule in the teaching interpreter, and the page shows which pool each form chose.
Why the forms can disagree
if and switch take the first rule that matches, in the order written. class match with starts_with or ends_with returns the longest matching entry, whatever the order (F5's class reference says so). With rules /api and /api/v2, the test value /api/v2/users goes to api_pool through if and switch, but to api_v2_pool through class match. The tool also flags a rule that can never fire because an earlier rule always matches first.
Worth knowing
- Lower-casing the value (
string tolower) makes the comparison case-insensitive, but then a rule value with capitals can never match; the tool warns about that. class matchhas no glob comparison, so a glob rule rules out the data-group form.- A rule value with a brace that has no partner is written with a backslash in front (
\{). Tcl counts the braces inside a braced body even between double quotes (rule 5 of the Tcl 8.4 syntax page), so a lone one would break the rule; real Tcl 8.4.6 stops withmissing close-brace. - For
HTTP::path, a test value is cut at its first question mark:HTTP::pathdoes not include the query string (F5'sHTTP::pathreference), so the rules compare only the part before it. - Record names with characters other than letters, digits and
_ . / : -are written in double quotes in thetmshdefinitions. That quoting has not been tried on a BIG-IP: list the data group intmshafter creating it and check the records. - The generated code follows the DevCentral iRules Style Guide (4-space indents, a priority on the event, braced expressions, braced variable names,
--onswitchandclass), and it passes this site's style checker with no findings.
Sources
- F5 iRules reference: class (read 2026-10-02)
- F5 iRules reference: Operators (read 2026-10-02)
- Tcl 8.4 manual: switch (read 2026-10-03)
- F5 K15650046: Tcl code injection security exposure (read 2026-10-03)
- F5 DevCentral: iRules Style Guide (read 2026-10-03)
- F5 iRules reference: priority (read 2026-10-03)
- F5 iRules reference: HTTP::path (read 2026-10-03)
- Tcl 8.4 manual: Tcl (the substitution rules) (read 2026-10-03)