Skip to content

Instantly share code, notes, and snippets.

@dankogai
Created September 9, 2010 09:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dankogai/571650 to your computer and use it in GitHub Desktop.
Save dankogai/571650 to your computer and use it in GitHub Desktop.
=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