Forum Discussion
Import iRule from iRule
Hi!
I wonder if anyone knows if it's possible to import an iRule depending on incoming parameters?
My case is that I don't want to have to complicated iRules with lots of "ifs" in them.
I want to have a "master" iRule which can select the correct iRule depending on which SSL profile that was selected.
For example:
when CLIENTSSL_CLIENTHELLO {
if {[PROFILE::clientssl name] == "/Common/default" } {
"Import and use iRule default"
}
if {[PROFILE::clientssl name] == "/Common/second" } {
"Import and use iRule second"
}
}
3 Replies
- What_Lies_Bene1
Cirrostratus
You could certainly compress all the if statements into a single switch statement quite easily which would simplify things somewhat. Let me know if you need some example code.
You can't call one iRule from another unfortunately but if you have large blocks of code that are similar perhaps stored procedures might help (v11.4 onwards): https://devcentral.f5.com/articles/getting-started-with-irules-procedures. If it's not attractive, being smart in general around naming conventions and common code etc. can often be just as good.
- gurrish_132043
Nimbostratus
Hi!
I think that I can achieve what I'm after by using this instead. Send the request to a virtual server where the iRule is defined.
when HTTP_REQUEST { Send request to a new virtual server virtual my_post_processing_server }- What_Lies_Bene1
Cirrostratus
OK, if you think that will work.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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