smp_86112
Jan 03, 2014Cirrostratus
Short iRule rewrite for efficiency/readability
I have a short iRule that is simple to understand. Logically, the iRule works by checking the host header against two known values and modifies the Host: header if neither match. This is how it's currently written:
when HTTP_REQUEST {
if { not (( [string tolower [HTTP::host]] equals "myapp1.domain.com" ) or
( [string tolower [HTTP::host]] equals "myapp2.domain.com" )) } {
HTTP::header replace "Host" [HTTP::host]:9070
}
}
Intuitively it seems this iRule could be written more efficiently, or at least easier to read. Normally I'd do this comparison in a SWITCH statement, but I can't seem to get SWITCH to work with negation. I know that there isn't a lot of efficiency to gain here, but I was hoping someone could give me some ideas on how they would accomplish this same logic?
Don't know that you need to negate the match, just perform no action on matching "myapp1" or "myapp2" and use the default case to perform your replace.