Skip to content

Commit

Permalink
Merge branch 'call_command'
Browse files Browse the repository at this point in the history
  • Loading branch information
landro committed Apr 29, 2016
2 parents e280367 + 43d44da commit 99ab81f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
15 changes: 15 additions & 0 deletions examples/example_irule_call.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package require -exact testcl 1.0.7
namespace import ::testcl::*

# Comment in to enable logging
#log::lvSuppressLE info 0

it "should redirect to the same url but using https" {
event HTTP_REQUEST
on HTTP::uri return "/bar"
on HTTP::host return "www.foo.com"
endstate HTTP::redirect https://www.foo.com/bar
run irules/call_irule.tcl call
}

stats
18 changes: 18 additions & 0 deletions irules/call_irule.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
rule call {

proc Redirect {url} {

HTTP::redirect $url

}

when HTTP_REQUEST {

set lowerUri [string tolower [HTTP::uri]]
set lowerHost [string tolower [HTTP::host]]

call Redirect https://$lowerHost$lowerUri

}

}
4 changes: 4 additions & 0 deletions src/onirule.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,7 @@ proc ::testcl::run {irule rulename} {
}
testcl::assertStringEquals "rule $rulename" $result
}

proc ::testcl::call args {
return [eval $args]
}

0 comments on commit 99ab81f

Please sign in to comment.