Forum Discussion
Andrea_Arquint
Nimbostratus
Jun 17, 2013using variable in a switch statement
Hi,
I would like to test a URI which is defined as a variable ($TEST_VAR):
when HTTP_REQUEST {
set TEST_VAR "item"
switch -glob [string tolower [HTTP::path]] {
"/$TEST_VAR/*" {...
spark_86682
Jun 17, 2013Historic F5 Account
This is possible. In Tcl, curly braces prevent variable substitution, and you have a set of curly braces surrounding the entire body of your switch statement, so "/$TEST_VAR/*" won't have its variable substituted. You should be able to fix this just by removing those outer braces around your switch body:
switch -glob [string tolower [HTTP::path]]
"/$TEST_VAR/*" {
log local0. "Matched pool 2 paths for [HTTP::uri]"
pool pool2
}
default {
log local0. "Hit default for [HTTP::uri]"
pool pool_default
}
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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