Persist using a string in an HTTP URI

Problem this snippet solves:

Sample Request:

https://x.x.x.x/abcdefgh-ijkl-mnop-qrst-0123456789#value="I%20am%20the%20one"&name="Mike"&p="0f2fd14389da8d85fbd215c789f7f7d5"

Requirement:

Extract Account ID from request URI such as ‘abcdefgh-ijkl-mnop-qrst-0123456789’

Then load balance traffic based on Account ID, and persist the same Account ID to the same backend pool member.

How to use this snippet:

Code :

when HTTP_REQUEST {
  set index1 [string first "/" [HTTP::uri] ] 
  set accountid [string range [HTTP::uri] [incr index1] end ]
  #log local0. "Account ID is: $accountid and will be persisted to same backend"
  persist hash $accountid
}
when LB_SELECTED {
  #log local0. "Backend is: [LB::server name]"
}
#Michelangelo Dorado | Nov 2021

Tested this on version:

No Version Found