Forum Discussion

James_41967's avatar
James_41967
Icon for Nimbostratus rankNimbostratus
Oct 10, 2017

iRule syntax error - undefined procedure

I'm trying to write this iRule that switches pools based on the path it sees, but I'm getting a syntax error:

01070151:3: Rule [/Common/test_irule_v4] error: /Common/test_irule_v4:17: error: [undefined procedure: default][default] /Common/test_irule_v4:13: error: [undefined procedure: drop ][if {[HTTP::path] starts_with "/patha"} { pool patha_prod_443_pool } elseif {[HTTP::path] starts_with "/" } { pool prod_443_pool }default { drop }]

when HTTP_REQUEST {
    switch -exact -- [string tolower [HTTP::host]] "url-uat.something.com" {
        if {[HTTP::path] starts_with "/patha"} {
            pool patha_uat_443_pool
        } elseif {[HTTP::path] starts_with "/pathb" } {
            pool pathb_uat_443_pool
        } elseif {[HTTP::path] starts_with "/" } {
            pool uat_443_pool
        } else {
            drop
        }
  } "url-prod.something.com" {
        if {[HTTP::path] starts_with "/patha"} {
            pool patha_prod_443_pool
        } elseif {[HTTP::path] starts_with "/" } {
            pool prod_443_pool
    }   default {
        drop
    }
}
}

1 Reply

  • Figured it out...had a close bracket in the wrong place!

    This works:

    when HTTP_REQUEST {
        switch -exact -- [string tolower [HTTP::host]] "url-uat.something.com" {
            if {[HTTP::path] starts_with "/patha"} {
                pool patha_uat_443_pool
            } elseif {[HTTP::path] starts_with "/pathb" } {
                pool pathb_uat_443_pool
            } elseif {[HTTP::path] starts_with "/" } {
                pool uat_443_pool
            } else {
                drop
            }
      } "url-prod.something.com" {
            if {[HTTP::path] starts_with "/patha"} {
                pool patha_prod_443_pool
            } elseif {[HTTP::path] starts_with "/" } {
                pool prod_443_pool
            }    
        }   default {
            drop
        }
    }