Is it possible to call a subroutine to share
in aFleX
Posted by TODDH
I have a customer that is looking to have a include function in an aFlex. Most of this can be accomplished by allowing multiple aFlexes bound to the same VIP as in 2.6, but do we have any plans to support calling common code as in the customers examples below?
Thanks!
-Todd-
** Aflex #1 test-aflex ** - currenly in use
# Test aflex functions
when HTTP_RESPONSE {
# Content-Location
if { [HTTP::header exists "Content-Location"] } {
regsub ":[TCP::remote_port]" [HTTP::header "Content-Location"] "" new_location
HTTP::header replace "Content-Location" $new_location
}
# Location
if { [HTTP::header exists "Location"] } {
regsub ":[TCP::remote_port]" [HTTP::header "Location"] "" new_location
HTTP::header replace "Location" $new_location
}
}
when HTTP_REQUEST {
if { [HTTP::uri] equals "/" } {
HTTP::uri /slash2.asp
}
if { [HTTP::uri] equals "/main" } {
HTTP::uri /main.asp
}
}
** Aflex #2 replace-content-location — currently in use
# Replace response location headers without the port details
when HTTP_RESPONSE {
# Content-Location
if { [HTTP::header exists "Content-Location"] } {
regsub ":[TCP::remote_port]" [HTTP::header "Content-Location"] "" new_location
HTTP::header replace "Content-Location" $new_location
}
# Location
if { [HTTP::header exists "Location"] } {
regsub ":[TCP::remote_port]" [HTTP::header "Location"] "" new_location
HTTP::header replace "Location" $new_location
}
}
** Aflex #3 test-aflex ** - tied with #4 to show include option
# Test aflex functions
when HTTP_RESPONSE {
[include::aflex “content-replace”]
}
}
when HTTP_REQUEST {
if { [HTTP::uri] equals "/" } {
HTTP::uri /slash2.asp
}
if { [HTTP::uri] equals "/main" } {
HTTP::uri /main.asp
}
}
** Aflex #4 content-replace — tied with #3 to show include option
# Replace response location headers without the port details
## This does NOT have a when xxx as it could be included in both http_response and http_request
# Content-Location
if { [HTTP::header exists "Content-Location"] } {
regsub ":[TCP::remote_port]" [HTTP::header "Content-Location"] "" new_location
HTTP::header replace "Content-Location" $new_location
}
# Location
if { [HTTP::header exists "Location"] } {
regsub ":[TCP::remote_port]" [HTTP::header "Location"] "" new_location
HTTP::header replace "Location" $new_location
}
** Aflex #5 test-aflex ** - tied with #6 to show expanded include option
# Test aflex functions
when HTTP_RESPONSE {
[include::aflex “aflex-library” “content-replace”]
}
when HTTP_REQUEST {
[include::aflex “aflex-library” “uri-slash”]
[include::aflex “aflex-library” “url-main”]
}
** Aflex #6 aflex-library tied with #5 and 6 to show expanded include option
When AFLEX_content-replace
{
# Replace response location headers without the port details
# Content-Location
if { [HTTP::header exists "Content-Location"] } {
regsub ":[TCP::remote_port]" [HTTP::header "Content-Location"] "" new_location
HTTP::header replace "Content-Location" $new_location
}
# Location
if { [HTTP::header exists "Location"] } {
regsub ":[TCP::remote_port]" [HTTP::header "Location"] "" new_location
HTTP::header replace "Location" $new_location
}
}
When AFLEX_slash {
if { [HTTP::uri] equals "/" } {
HTTP::uri /slash2.asp
}
}
When AFLEX_main {
if { [HTTP::uri] equals "/main" } {
HTTP::uri /main.asp
}
}
## note this refers to a routine in the same aflex
When AFLEX_http_response
when HTTP_RESPONSE {
[include::aflex “aflex-library” “content-replace”]
}
}
** Aflex #7 http-response ** - tied with #6 to show expanded include option
# process http response for standard requests without extra options
[include::aflex “aflex-library” “http_response”]
I have a customer that is looking to have a include function in an aFlex. Most of this can be accomplished by allowing multiple aFlexes bound to the same VIP as in 2.6, but do we have any plans to support calling common code as in the customers examples below?
Thanks!
-Todd-
** Aflex #1 test-aflex ** - currenly in use
# Test aflex functions
when HTTP_RESPONSE {
# Content-Location
if { [HTTP::header exists "Content-Location"] } {
regsub ":[TCP::remote_port]" [HTTP::header "Content-Location"] "" new_location
HTTP::header replace "Content-Location" $new_location
}
# Location
if { [HTTP::header exists "Location"] } {
regsub ":[TCP::remote_port]" [HTTP::header "Location"] "" new_location
HTTP::header replace "Location" $new_location
}
}
when HTTP_REQUEST {
if { [HTTP::uri] equals "/" } {
HTTP::uri /slash2.asp
}
if { [HTTP::uri] equals "/main" } {
HTTP::uri /main.asp
}
}
** Aflex #2 replace-content-location — currently in use
# Replace response location headers without the port details
when HTTP_RESPONSE {
# Content-Location
if { [HTTP::header exists "Content-Location"] } {
regsub ":[TCP::remote_port]" [HTTP::header "Content-Location"] "" new_location
HTTP::header replace "Content-Location" $new_location
}
# Location
if { [HTTP::header exists "Location"] } {
regsub ":[TCP::remote_port]" [HTTP::header "Location"] "" new_location
HTTP::header replace "Location" $new_location
}
}
** Aflex #3 test-aflex ** - tied with #4 to show include option
# Test aflex functions
when HTTP_RESPONSE {
[include::aflex “content-replace”]
}
}
when HTTP_REQUEST {
if { [HTTP::uri] equals "/" } {
HTTP::uri /slash2.asp
}
if { [HTTP::uri] equals "/main" } {
HTTP::uri /main.asp
}
}
** Aflex #4 content-replace — tied with #3 to show include option
# Replace response location headers without the port details
## This does NOT have a when xxx as it could be included in both http_response and http_request
# Content-Location
if { [HTTP::header exists "Content-Location"] } {
regsub ":[TCP::remote_port]" [HTTP::header "Content-Location"] "" new_location
HTTP::header replace "Content-Location" $new_location
}
# Location
if { [HTTP::header exists "Location"] } {
regsub ":[TCP::remote_port]" [HTTP::header "Location"] "" new_location
HTTP::header replace "Location" $new_location
}
** Aflex #5 test-aflex ** - tied with #6 to show expanded include option
# Test aflex functions
when HTTP_RESPONSE {
[include::aflex “aflex-library” “content-replace”]
}
when HTTP_REQUEST {
[include::aflex “aflex-library” “uri-slash”]
[include::aflex “aflex-library” “url-main”]
}
** Aflex #6 aflex-library tied with #5 and 6 to show expanded include option
When AFLEX_content-replace
{
# Replace response location headers without the port details
# Content-Location
if { [HTTP::header exists "Content-Location"] } {
regsub ":[TCP::remote_port]" [HTTP::header "Content-Location"] "" new_location
HTTP::header replace "Content-Location" $new_location
}
# Location
if { [HTTP::header exists "Location"] } {
regsub ":[TCP::remote_port]" [HTTP::header "Location"] "" new_location
HTTP::header replace "Location" $new_location
}
}
When AFLEX_slash {
if { [HTTP::uri] equals "/" } {
HTTP::uri /slash2.asp
}
}
When AFLEX_main {
if { [HTTP::uri] equals "/main" } {
HTTP::uri /main.asp
}
}
## note this refers to a routine in the same aflex
When AFLEX_http_response
when HTTP_RESPONSE {
[include::aflex “aflex-library” “content-replace”]
}
}
** Aflex #7 http-response ** - tied with #6 to show expanded include option
# process http response for standard requests without extra options
[include::aflex “aflex-library” “http_response”]
0
Comments
We don't offer this otion today.
But as you mentioned our 2.6 enhancements:
. Multiple aFleX can be bound to the same VIP
. Same aFleX can be bound to different VIP (actually this was available in 2.4 too)
provides lots of flexibility and ease of use.
And more importantly with close to no impact on AX performance and scalability!
Now as always, if there is a business case and this would provide great benefits: our engineering loves challenges