Forum Discussion
Josh_B_152229
May 20, 2015Nimbostratus
Calling procs dynamically
I have successfully tested calling procs like this:
eval call [string tolower {HTTP::host}]::procName
However, I'm trying to stop using HTTP::host directly because the TCL checker freaks comp...
Josh_B_152229
Nimbostratus
Much progress has been made. What I found is incredibly frustrating, but I assume it's because I was (somehow) "doing it wrong."
The goal was to dynamically call a proc named
http_request
inside a rule that was named the same as an expected [HTTP::host]
(something that would resolve to the virtual server and be handled by the rule). I have had much success with something very similar before where I set a variable based on a datagroup lookup and performed something simlar to eval call [$variable]::procName
.
As indicated above, the variable substitution must not act how I think it should and the following not only does not work, but also crashes TMM on 11.6.0 HF3:
set host [string tolower [HTTP::host]]
set uri [string tolower [HTTP::uri]]
eval call [string tolower {HTTP::host}]::http_request $host $uri
My initial testing shows that defining the entire proc to call as a
string
works, but using variable substitution ($host
instead of [string tolower [HTTP::host]]
) when setting http_request
below doesn't work. Not much testing has been done, yet, but the following appears to behave as I expect it:
set host [string tolower [HTTP::host]]
set uri [string tolower [HTTP::uri]]
set http_request "[string tolower [HTTP::host]]::http_request"
eval call $http_request $host $uri
Josh_B_152229
May 21, 2015Nimbostratus
Update: The last line also works when passing TCL words instead of the variables like so:
`eval call $http_request [HTTP::host] [HTTP::uri]`
As "expected" as that is, it's exciting to me because I have seen so much unexpected behavior with variable substitution lately.
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects