/usr/share/perl5/Plack/Middleware/Status.pm is in libplack-middleware-status-perl 1.101150-2.
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | #
# This file is part of Plack-Middleware-Status
#
# This software is copyright (c) 2010 by Patrick Donelan.
#
# This is free software; you can redistribute it and/or modify it under
# the same terms as the Perl 5 programming language system itself.
#
package Plack::Middleware::Status;
BEGIN {
$Plack::Middleware::Status::VERSION = '1.101150';
}
# ABSTRACT: Plack Middleware for mapping urls to status code-driven responses
use strict;
use parent qw/Plack::Middleware/;
use HTTP::Status;
use Plack::Util::Accessor qw( path status );
use Carp;
sub call {
my $self = shift;
my $env = shift;
my $res = $self->_handle($env);
return $res if $res;
return $self->app->($env);
}
sub _handle {
my ( $self, $env ) = @_;
my $path_match = $self->path;
my $status = $self->status;
my $path = $env->{PATH_INFO};
for ($path) {
my $matched = 'CODE' eq ref $path_match ? $path_match->($_) : $_ =~ $path_match;
return unless $matched;
}
my $message = HTTP::Status::status_message($status) or do {
carp "Invalid HTTP status: $status";
return;
};
return [ $status, [ 'Content-Type' => 'text/plain', 'Content-Length' => length($message) ], [$message] ];
}
1;
__END__
=pod
=head1 NAME
Plack::Middleware::Status - Plack Middleware for mapping urls to status code-driven responses
=head1 VERSION
version 1.101150
=head1 SYNOPSIS
# app.psgi
use Plack::Builder;
my $app = sub {
# ...
};
builder {
enable 'Status', path => qr{/not-implemented}, status => 501;
$app;
};
=head1 AUTHOR
Patrick Donelan <pat@patspam.com>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Patrick Donelan.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|