Forum Discussion
string map insert
I have the following uris that I would like to map a string and prepend a value to the string (in the examples below snt )
Any help with the iRules would be greatly appreciated
"/here.there/service/v1/customers/qualification" "/snt/here.there/service/v1/customers/qualification"
then use pool
"/here.there/service/v1/accounts/{accountNumber}" "/snt/here.there/service/v1/accounts/{accountNumber}"
then use pool
"/here.there/service/v1/accounts/{accountNumber}/paymentprofile" "/snt/here.there/service/v1/accounts/{accountNumber}/paymentprofile"
then use pool
5 Replies
- JG
Cumulonimbus
Is the "{accountNumber} variable? What's the format?
- JG
Cumulonimbus
Are these URLs literal, or do they include their sub-directories/paths?
- ChrisRodrigues
Nimbostratus
The urls are literal. Thanks
- JG
Cumulonimbus
Try something like this one then:
when HTTP_REQUEST { switch -- [string tolower [HTTP::uri]] { "/here.there/service/v1/customers/qualification" { HTTP::uri /snt[HTTP::uri] pool pool_1 } "/here.there/service/v1/accounts/\{accountNumber\}/paymentprofile" { HTTP::uri /snt[HTTP::uri] pool pool_2 } "/here.there/service/v1/accounts/\{accountNumber\}" { HTTP::uri /snt[HTTP::uri] pool pool_3 } default { pool default_pool } } }
.
- ChrisRodrigues
Nimbostratus
Thanks JG for the quick responses. I tried this that worked. I could do this because I'm using the same pool for all my earlier examples.
when HTTP_REQUEST {
set uri [HTTP::uri [string map {"/here.there " "/snt/here.there "}[HTTP::uri]]]
pool pool_name
}
realized I was just pre-pending snt (more like a find and replace)
Thanks again!
Recent Discussions
Related Content
* 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