Skip to content

Commit

Permalink
added experimental to_psgi method to Mojo::Server::PSGI
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 18, 2012
1 parent 91115f1 commit 442e164
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 18 deletions.
1 change: 1 addition & 0 deletions Changes
@@ -1,6 +1,7 @@
This file documents the revision history for Perl extension Mojolicious.

2.51 2012-02-19 00:00:00
- Added EXPERIMENTAL to_psgi method to Mojo::Server::PSGI.
- Removed experimental status from around_dispatch hook.
- Removed experimental status from emit_chain method in
Mojolicious::Plugins.
Expand Down
16 changes: 14 additions & 2 deletions lib/Mojo/Server/PSGI.pm
Expand Up @@ -49,6 +49,11 @@ sub run {
\@headers, Mojo::Server::PSGI::_IO->new(tx => $tx)];
}

sub to_psgi {
(my $self = shift)->app;
return sub { $self->run(@_) }
}

# "Wow! Homer must have got one of those robot cars!
# *Car crashes in background*
# Yeah, one of those AMERICAN robot cars."
Expand Down Expand Up @@ -105,7 +110,7 @@ Mojo::Server::PSGI - PSGI server
# Resume transaction
$tx->resume;
});
my $app = sub { $psgi->run(@_) };
$psgi->to_psgi;
=head1 DESCRIPTION
Expand All @@ -127,7 +132,14 @@ implements the following new ones.
my $res = $psgi->run($env);
Run PSGI.
Run L<PSGI>.
=head2 C<to_psgi>
my $app = $psgi->to_psgi;
Turn L<Mojo> application into L<PSGI> application. Note that this method is
EXPERIMENTAL and might change without warning!
=head1 SEE ALSO
Expand Down
11 changes: 1 addition & 10 deletions lib/Mojolicious/Command/psgi.pm
Expand Up @@ -8,16 +8,7 @@ has usage => "usage: $0 psgi\n";

# "In the end it was not guns or bombs that defeated the aliens,
# but that humblest of all God's creatures... the Tyrannosaurus Rex."
sub run {
my $self = shift;

# Preload
my $psgi = Mojo::Server::PSGI->new;
$psgi->app;

# Return app callback
return sub { $psgi->run(@_) };
}
sub run { Mojo::Server::PSGI->new->to_psgi }

1;
__END__
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Guides.pod
Expand Up @@ -102,7 +102,7 @@ WebSocket server with support for zero downtime software upgrades

=item L<Mojo::Server::CGI>, L<Mojo::Server::PSGI>

Transparent CGI and PSGI support out of the box.
Transparent CGI and L<PSGI> support out of the box.

=item L<Mojo::Template>

Expand Down
8 changes: 4 additions & 4 deletions lib/Mojolicious/Guides/Cookbook.pod
Expand Up @@ -153,10 +153,10 @@ automatically detect that it is executed as a C<CGI> script.
=head2 PSGI/Plack

L<PSGI> is an interface between Perl web frameworks and web servers, and
L<Plack> is a Perl module and toolkit that contains PSGI middleware, helpers
and adapters to web servers. L<PSGI> and L<Plack> are inspired by Python's
WSGI and Ruby's Rack. L<Mojolicious> applications are ridiculously simple to
deploy with L<Plack>.
L<Plack> is a Perl module and toolkit that contains L<PSGI> middleware,
helpers and adapters to web servers. L<PSGI> and L<Plack> are inspired by
Python's WSGI and Ruby's Rack. L<Mojolicious> applications are ridiculously
simple to deploy with L<Plack>.

$ plackup ./script/myapp
HTTP::Server::PSGI: Accepting connections at http://0:5000/
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Lite.pm
Expand Up @@ -123,7 +123,7 @@ There is also a helper command to generate a small example application.
=head2 Commands
All the normal L<Mojolicious::Commands> are available from the command line.
Note that CGI and PSGI environments can usually be auto detected and will
Note that CGI and L<PSGI> environments can usually be auto detected and will
just work without commands.
$ ./myapp.pl daemon
Expand Down

0 comments on commit 442e164

Please sign in to comment.