Referencing a class with a variable

I’m wondering if I can reference a class with a variable?

Will the class reference below evaluate to $::myclass?

when HTTP_REQUEST {

set uri_discards myclass

if {[matchclass [HTTP::uri] starts_with $::{$uri_discards}]}{

discard

}

}

I also noticed that I don’t get any errors loading up this rule, even though neither class “myclass” nor “uri_discards” exists, so I’m wondering how much classname verification I might need to perform using variables in this manner?

thanks

/deb

There’s actually a tech tip about dynamically declaring class names here: Click here

Check it out and let us know if you’ve got any further questions.

Thanks,

-Colin

sweet, thanks!

so using eval against the findclass command results validates the cookie value for its intended use - finding the related pool or branching elsewhere if not found:

I take it there’s no graceful way to do it without setting the 2 variables?

Colin,

The link in this post is broken? Getting access denied viewing tab. Does this article still exist? Is it still relevant?

Jason

Hi Jason,

This is the article Colin was referring to:

Dynamically declaring a class name based on Request info

http://devcentral.f5.com/Default.aspx?tabid=63&articleType=ArticleView&articleId=37

I think you might be able to use subst as well:

TCL subst man page

http://www.tcl.tk/man/tcl8.4/TclCmd/subst.htm

Examples:

http://devcentral.f5.com/Default.aspx?tabid=53&view=topic&postid=23503&ptarget=23562

Aaron