Permalink
Browse files

teardown

  • Loading branch information...
1 parent 196fe43 commit 95db9f4f8435715fbbd16f431966deab2bd812a2 @moritz committed Jun 27, 2010
Showing with 11 additions and 4 deletions.
  1. +9 −3 lib/CGI/Application.pm
  2. +2 −1 t/basic.t
View
@@ -15,9 +15,10 @@ has %.header-props is rw = {};
has $.current-runmode is rw;
has %.callbacks = (
- prerun => [<prerun>],
- postrun => [<postrun>],
- error => [<error>],
+ prerun => [<prerun>],
+ postrun => [<postrun>],
+ error => [<error>],
+ teardown => [<teardown>],
);
# the CGI object or hash
@@ -45,6 +46,9 @@ multi method run() {
my $output = $headers ~ $body;
print $output unless $*CGI_APP_RETURN_ONLY || %*ENV<CGI_APP_RETURN_ONLY>;
+
+ $.call-hook('teardown');
+
return $output;
}
@@ -132,4 +136,6 @@ method postrun(*@args) {
# do nothing for now.
}
+method teardown() {};
+
# vim: ft=perl6
View
@@ -127,6 +127,7 @@ if 0 {
method prerun($) { $tracker ~= 'prerun' }
method postrun($) { $tracker ~= ' postrun' }
method doit() { $tracker ~= ' doit'; 42 }
+ method teardown() { $tracker ~= ' teardown'; }
}
my $app = WithHook.new(query => { rm => 'doit' });
response-like(
@@ -135,7 +136,7 @@ if 0 {
42,
'WithHook',
);
- is $tracker, 'prerun doit postrun',
+ is $tracker, 'prerun doit postrun teardown',
'all trackers were called in the right order';
}

0 comments on commit 95db9f4

Please sign in to comment.