1 package Web::Dispatch::Wrapper;
7 our @EXPORT = qw(dispatch_wrapper redispatch_to response_filter);
9 extends 'Plack::Middleware';
11 has 'wrapper' => (is => 'ro', required => 1);
13 sub dispatch_wrapper (&) {
15 __PACKAGE__->from_code($code);
19 my ($class, $code) = @_;
20 $class->new(wrapper => $code);
25 __PACKAGE__->from_code(sub {
26 $_[1]->({ %{$_[0]}, PATH_INFO => $new_path });
30 sub response_filter (&) {
32 __PACKAGE__->from_code(sub {
33 my @result = $_[1]->($_[0]);
43 my $code = $_[0]->wrapper;
45 sub { $code->($_[0], $app) }