# Customer Defined Functions

**URL:** <https://community.f5.com/t/customer-defined-functions/1602>\
**Category:** Technical Forums\
**Tags:** dev, irules, devops, application-delivery\
**Created:** [February 3, 2010, 2:51am UTC](https://community.f5.com/t/customer-defined-functions/1602 "2010-02-03T02:51:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ian\_105608](https://avatars.discourse-cdn.com/v4/letter/i/d6d6ee/32.png) [@Ian\_105608](https://community.f5.com/u/Ian_105608)\
**Post date:** [February 3, 2010, 2:51am UTC](https://community.f5.com/t/customer-defined-functions/1602/1 "2010-02-03T02:51:36Z")

</div>

Gday,

We are using HTTP::path to do HTTP routing decisions. We have some fairly long irules that have many applications on a virtual server pointing to several different servers.

One thing we’d like to do is emulate Apache named virtual hosting in an iRule. The thing holding us back is we’d end up with mass nested difficult to read irules like :

when HTTP\_REQUEST {

if { [HTTP::host] equals “site” } {

if { [HTTP::path] starts\_with “/” } {

pool blah

}

}

}

Ad naseum for multiple hosts / paths. What I’d like to do is change the nested if to call another irule that contains the path decision.

So something like :

when HTTP\_REQUEST {

if { [HTTP::host] equals “site” } {

call somesite\_directory(request\_object);

}

}

Did a bit of googling but couldn’t find anything.

Any ideas?

Cheers,

Ian

---

<div class="post-metadata">

**Author:** ![hoolio](https://avatars.discourse-cdn.com/v4/letter/h/f6c823/32.png) [@hoolio](https://community.f5.com/u/hoolio)\
**Post date:** [February 3, 2010, 5:09pm UTC](https://community.f5.com/t/customer-defined-functions/1602/2 "2010-02-03T17:09:05Z")

</div>

Hi Ian,

There has been discussion here about supporting user defined functions. Last I read they’re still under consideration.

However, for your scenario, I think using a datagroup mapping the host, paths and pool would be more efficient (and possible in current versions). If you’re on v10, you can use the new class command ([Click here](http://devcentral.f5.com/wiki/default.aspx/iRules/class)). For 9.x, you can use the findclass or TCL list commands to look up the corresponding pool.

For examples, you can check the wiki pages or search the iRules forums for findclass, “http::host”, class, etc.

Another option would be to use the ProxyPassV9 or ProxyPassV10 iRules to do this:

iRule codeshare ([Click here](http://devcentral.f5.com/wiki/default.aspx/iRules/codeshare))

Aaron
