Plack::Handler::Apache2::Registry - Runs .psgi files.


Plack documentation Contained in the Plack distribution.

Index


Code Index:

NAME

Top

Plack::Handler::Apache2::Registry - Runs .psgi files.

SYNOPSIS

Top

  PerlModule Plack::Handler::Apache2::Registry;
  <Location /psgi-bin>
  SetHandler modperl
  PerlHandler Plack::Handler::Apache2::Registry
  </Location>

DESCRIPTION

Top

This is a handler module to run any *.psgi files with mod_perl2, just like ModPerl::Registry.

AUTHOR

Top

Masahiro Honma <hiratara@cpan.org>

SEE ALSO

Top

Plack::Handler::Apache2


Plack documentation Contained in the Plack distribution.

package Plack::Handler::Apache2::Registry;
use strict;
use warnings;
use Try::Tiny;
use Apache2::Const;
use Apache2::Log;
use parent qw/Plack::Handler::Apache2/;

sub handler {
    my $class = __PACKAGE__;
    my ($r) = @_;

    return try {
        my $app = $class->load_app( $r->filename );
        $class->call_app( $r, $app );
    }catch{
        if(/no such file/i){
            $r->log_error( $_ );
            return Apache2::Const::NOT_FOUND;
        }else{
            $r->log_error( $_ );
            return Apache2::Const::SERVER_ERROR;
        }
    };
}

# Overriding
sub fixup_path {
    my ($class, $r, $env) = @_;
    $env->{PATH_INFO} =~ s{^$env->{SCRIPT_NAME}}{};
}

1;

__END__