Eric_123944
Jan 06, 2017Nimbostratus
Can switch be used to compare HTTP::host against multiple datagroups?
We currently serve some pages directly from the F5 by matching
[HTTP::host]
to some datagroups using if
/elseif
. I'm wondering if this could be replaced using switch
to improve legibility and make it easier to modify or add more in the future.
Example
if {[class match [string tolower [HTTP::host]] equals SiteMaintenance] } {
HTTP::respond 200 content [ifile get "Maintenance_html"] "Content-Type" "text/html" "Edge-control" "max-age=5m"
} elseif {[class match [string tolower [HTTP::host]] equals SiteMoved] } {
HTTP::respond 200 content [ifile get "SiteMoved_html"]
} elseif {[class match [string tolower [HTTP::host]] equals SiteDisabled] } {
HTTP::respond 200 content [ifile get "SiteDisabled_html"]
}