1package Plack::Handler::Apache2::Registry;
2use strict;
3use warnings;
4use Try::Tiny;
5use Apache2::Const;
6use Apache2::Log;
7use parent qw/Plack::Handler::Apache2/;
8
9sub handler {
10    my $class = __PACKAGE__;
11    my ($r) = @_;
12
13    return try {
14        my $app = $class->load_app( $r->filename );
15        $class->call_app( $r, $app );
16    }catch{
17        if(/no such file/i){
18            $r->log_error( $_ );
19            return Apache2::Const::NOT_FOUND;
20        }else{
21            $r->log_error( $_ );
22            return Apache2::Const::SERVER_ERROR;
23        }
24    };
25}
26
27# Overriding
28sub fixup_path {
29    my ($class, $r, $env) = @_;
30    $env->{PATH_INFO} =~ s{^$env->{SCRIPT_NAME}}{};
31}
32
331;
34
35__END__
36
37=head1 NAME
38
39Plack::Handler::Apache2::Registry - Runs .psgi files.
40
41=head1 SYNOPSIS
42
43  PerlModule Plack::Handler::Apache2::Registry;
44  <Location /psgi-bin>
45  SetHandler modperl
46  PerlHandler Plack::Handler::Apache2::Registry
47  </Location>
48
49=head1 DESCRIPTION
50
51This is a handler module to run any *.psgi files with mod_perl2,
52just like ModPerl::Registry.
53
54=head1 AUTHOR
55
56Masahiro Honma E<lt>hiratara@cpan.orgE<gt>
57
58=head1 SEE ALSO
59
60L<Plack::Handler::Apache2>
61
62=cut
63
64