/usr/share/perl5/Web/Dispatch/Wrapper.pm is in libweb-simple-perl 0.031-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | package Web::Dispatch::Wrapper;
use strictures 1;
use Moo;
use Exporter 'import';
our @EXPORT = qw(dispatch_wrapper redispatch_to response_filter);
extends 'Plack::Middleware';
has 'wrapper' => (is => 'ro', required => 1);
sub dispatch_wrapper (&) {
my ($code) = @_;
__PACKAGE__->from_code($code);
}
sub from_code {
my ($class, $code) = @_;
$class->new(wrapper => $code);
}
sub redispatch_to {
my ($new_path) = @_;
__PACKAGE__->from_code(sub {
$_[1]->({ %{$_[0]}, PATH_INFO => $new_path });
});
}
sub response_filter (&) {
my ($code) = @_;
__PACKAGE__->from_code(sub {
my @result = $_[1]->($_[0]);
if (@result) {
$code->(@result);
} else {
()
}
});
}
sub to_app {
my $code = $_[0]->wrapper;
my $app = $_[0]->app;
sub { $code->($_[0], $app) }
}
1;
|