Created
September 9, 2010 09:33
-
-
Save dankogai/571650 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=head1 NAME | |
Plack::Loader - (auto)load PSGI/Plack Servers | |
=head1 SYNOPSIS | |
#!/usr/bin/env perl | |
# printenv-like app in PSGI, F?CGI, AnyEvent, Coro, POE or Danga::Socket | |
use strict; | |
use warnings; | |
use Data::Dumper; | |
use Plack::Loader; | |
my $app = sub { | |
my $env = shift; | |
return [ 200, [ 'Content-Type' => 'text/plain' ], [ Dumper($env) ] ]; | |
}; | |
Plack::Loader->auto->run($app); | |
=head2 MORE SYNOPSIS | |
# auto-select server backends based on env vars | |
use Plack::Loader; | |
Plack::Loader->auto(%args)->run($app); | |
# specify the implementation with a name | |
Plack::Loader->load('FCGI', %args)->run($app); | |
=head1 DESCRIPTION | |
Plack::Loader is a factory class to load one of L<Plack::Handler> subclasses based on the environment. | |
=head1 AUTOLOADING | |
C<< Plack::Loader->auto(%args) >> will autoload the most correct | |
server implementation by guessing from environment variables and Perl INC | |
hashes. | |
=over 4 | |
=item PLACK_SERVER | |
env PLACK_SERVER=AnyEvent ... | |
Plack users can specify the specific implementation they want to load | |
using the C<PLACK_SERVER> environment variable. | |
=item PHP_FCGI_CHILDREN, GATEWAY_INTERFACE | |
If there's one of FastCGI or CGI specific environment variables set, | |
use the corresponding server implementation. | |
=item %INC | |
If one of L<AnyEvent>, L<Coro>, L<POE> or L<Danga::Socket> is loaded, | |
the relevant implementation will be loaded. | |
=back | |
=cut |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment