KingMeow_3883
Apr 01, 2015Altostratus
Calling commands by string / reflection
Hi,
Is there any way to call iRule commands by string? For example, can I turn the string "starts_with" into a variable which calls the command 'starts_with'?. I'm trying to make an iRule that interpret strings in a datagroup into commands efficiently, rather than using a bunch of switch statements.
To elaborate, say my iRule has just read a datagroup value, performed a split procedure on it, and returned a list with the values "HTTP::URI" , "starts_with" and "/blah" and then stored them into the variables $a , $b and $c respectively.
I want to be able to do something like
if {[$a $b $c]}
and have it be interpreted as though it was 'if {"[HTTP::URI] starts_with /blah"}
`.
in c this is called 'reflection', is there an iRule equivalent? http://www.dotnetperls.com/methodinfo-invoke
Thanks.