From: Florian Ragwitz Date: Fri, 3 Dec 2010 16:00:19 +0000 (+0000) Subject: Don't build the psgi app twice X-Git-Tag: 5.89000~16 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=518576166dfa8607e2a0384ac46fa061dd931884 Don't build the psgi app twice --- diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index f91eb26..2c96b15 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -2402,7 +2402,7 @@ Starts the engine. =cut -sub run { my $c = shift; return $c->engine->run( $c, @_ ) } +sub run { my $c = shift; return $c->engine->run( $c, $c->psgi_app, @_ ) } =head2 $c->set_action( $action, $code, $namespace, $attrs ) diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index 1fdbfeb..7a98187 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -780,13 +780,12 @@ run method on the server passed in.. =cut sub run { - my ($self, $app, @args) = @_; + my ($self, $app, $psgi, @args) = @_; + # FIXME - Do something sensible with the options we're passed my $server = pop @args if blessed $args[-1]; $server ||= Plack::Loader->auto(); # We're not being called from a script, # so auto detect what backend to run on. # This does *NOT* cover mod_perl. - # FIXME - Do something sensible with the options we're passed - my $psgi = $self->build_psgi_app($app, @args); $server->run($psgi); } @@ -812,12 +811,12 @@ sub build_psgi_app { $psgi_app = Plack::Middleware::Conditional->wrap( $psgi_app, + builder => sub { Plack::Middleware::ReverseProxy->wrap($_[0]) }, condition => sub { my ($env) = @_; return if $app->config->{ignore_frontend_proxy}; return $env->{REMOTE_ADDR} eq '127.0.0.1' || $app->config->{using_frontend_proxy}; }, - builder => sub { Plack::Middleware::ReverseProxy->wrap($_[0]) }, ); return $psgi_app;