Forum Discussion
TMaCEvans_92750
Jan 17, 2011Nimbostratus
nesting switch within aif statement
I'm trying to nest a switch statement in a if statement but am getting a parse error
[parse error: PARSE syntax 302 syntax\ error\ in\ expression\ \"\ switch\ -glob\ \[string\ tolower\ \[HTTP::u...
Chris_Miller
Jan 17, 2011Altostratus
Here's what I came up with.
1. I got rid of the "URI::path" and justed used "HTTP::path." Any reason you were using both?
2. I'm assuming your "| |" meant "or." I'm admittedly a bit rusty on that front. :-P.
3. I referenced "pool3" twice in the "WebSocket" part as I wanted to cover both "if" statements. That might not have been necessary but I would have expected the second if to use the default pool if one wasn't selected.
4. Rather than both checking to see whether the header existed and checking to see what it contained, I simply checked whether the header contained the "WebSocket" value. If the header didn't exist, it obviously wouldn't contain said value so I assumed I could do away with that check.
5. You can't really "if" a switch statement which is why you were running into problems.
Give this a shot and let me know what you see.
when HTTP_REQUEST {
if { [string tolower [HTTP::path]] starts_with "/xyz/" or [string tolower [HTTP::query]] contains "xy=9" } {
if { [HTTP::method] eq "GET" and [HTTP::header "Upgrade"] contains "WebSocket" } {
HTTP::disable
pool pool3 }
pool pool3
} else {
switch -glob [string tolower [HTTP::uri]] {
"/fr/app*" { pool pool2 }
default { pool pool1 }
}
}
}
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