You can find a good documentation of iRule events tips and tricks in this link: https://devcentral.f5.com/articles/irules-101-04-switch
I will try to be clear, here we go:
This event triggers in http request
when HTTP_REQUEST {
this will store the first http path segment in lower case
so, we'll define the request traffic direction as needed
example:
request for url: http://mywebservice.com/DEV/service
[HTTP::host] ==> mywebservice.com (not used, just to understand)
[HTTP::path] ==> /DEV/service
[split [HTTP::path] "/"] ==> [split /DEV/service "/"] ==> { DEV service}
[lindex { DEV service} 1] ==> DEV
[string tolower {DEV}] ==> dev (this is useful when web service is case insensitive (windows eg))
set path ==> stores the value "dev"
set path [string tolower [lindex [split [HTTP::path] "/"] 1]]
this will verify the value stored in path variable
switch -glob $path {
case value is "dev", request goes to the pool-dev
"dev" { pool pool-dev }
case value is "ct", request goes to the pool-ct
"ct" { pool pool-ct }
case value is "uat", request goes to the pool-uat
"uat" { pool pool-uat }
otherwise, show the help page
default {
here we will write the response content page
HTTP::respond 200 content "`Available resource options````