Forum Discussion
Can switch be used to compare HTTP::host against multiple datagroups?
I am not 100% sure but I don't think you can use "class match" within "switch".
If you are looking to lower the lines of code and make it easier to make changes, you can do something like this possibly:
when HTTP_REQUEST {
set HOST [string tolower [HTTP::host]]
set MAINT_PAGE [class match -value $HOST equals CLASS_MAINTENANCE]
if { $MAINT_PAGE ne "" } {
HTTP::respond 200 content [ifile get $MAINT_PAGE] "Content-Type" "text/html" "Edge-control" "max-age=5m"
}
}
In this case, the CLASS_MAINTENANCE is a datagroup that contains the domain and corresponding maintenance page like this:
a.domain.com := Maintenance_html
b.domain.com := SiteMoved_html
c.domain.com := SiteDisabled_html
You can keep adding more domains and relevant maintenance page to this CLASS_MAINTENANCE data group as you scale and the lines of code remain the same. This hasn't been tested but it should give you an alternate idea. Let us know if it works.
Recent Discussions
Related Content
* 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