From abbbda554cd5c2b54435dc695694a7169baf3fc9 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 7 Jan 2011 13:12:58 -0600 Subject: don't keep recreating the ::Proxy object --- lib/Plack/Client.pm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/Plack/Client.pm b/lib/Plack/Client.pm index 118e818..ba12ba9 100644 --- a/lib/Plack/Client.pm +++ b/lib/Plack/Client.pm @@ -80,7 +80,8 @@ sub new { if exists($params{apps}) && ref($params{apps}) ne 'HASH'; bless { - apps => $params{apps}, + apps => $params{apps}, + proxy => Plack::App::Proxy->new, }, $class; } @@ -92,7 +93,8 @@ Returns the C hashref that was passed to the constructor. =cut -sub apps { shift->{apps} } +sub apps { shift->{apps} } +sub _proxy { shift->{proxy} } =method app_for @@ -252,7 +254,8 @@ sub _app_from_req { elsif ($scheme eq 'http' || $scheme eq 'https') { my $uri = $uri->clone; $uri->path('/'); - $app = Plack::App::Proxy->new(remote => $uri->as_string)->to_app; + $req->env->{'plack.proxy.remote'} = $uri->as_string; + $app = $self->_proxy; } die "Couldn't find app" unless $app; -- cgit v1.2.3-54-g00ecf