Forum Discussion

farache_28983's avatar
farache_28983
Icon for Nimbostratus rankNimbostratus
Jan 23, 2013

Switch Statement - action

I am building an irule for a specific project and thought of doing a piece of it like this..

 

when HTTP_REQUEST priority 150 {

 

if { $preprodpoolcheck == 1} {

 

if {[class match [string tolower [HTTP::path]] contains Domain_collapse_uri_list]} {

 

set ASPserver 1

 

log local0.alert "Request is for ASP server"

 

} else {

 

[switch -glob [string tolower [HTTP::path]] {

 

"*.asp" -

 

"/images/*" -

 

"/extras/images/*" {set ASPserver 1}}]

 

[switch -glob [string tolower [HTTP::uri]] {

 

"*/default.asp" {set JSPserver 1}

 

default {set JSPserver 1}}]

 

}

 

}

 

log local0.alert "Selected Pre-Prod Servers"

 

}

 

 

Is this really possible? I would guess yes... but again i am not an expert...

 

I am getting this error in the logs

 

Rule /Common/pre-prod : PrePROD POOL is LIVE

 

Jan 23 17:55:15 tmm err tmm[9493]: 01220001:3: TCL error: /Common/pre-prod - invalid command name "" while executing "[switch -glob [string tolower [HTTP::path]] { "*.asp" - "/images/*" - "/extras/images/*" {set ASPserver 1}}]"

 

 

I want to set a value to a variable depending on the URL selected.

 

Any ideas?

 

  • Remove the first [ from the following;

    
    [switch -glob [string tolower [HTTP::path]] {
    [switch -glob [string tolower [HTTP::uri]] {