summaryrefslogtreecommitdiffstats
path: root/lib/Plack/Client/Backend/http.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Plack/Client/Backend/http.pm')
-rw-r--r--lib/Plack/Client/Backend/http.pm28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/Plack/Client/Backend/http.pm b/lib/Plack/Client/Backend/http.pm
new file mode 100644
index 0000000..9982cd1
--- /dev/null
+++ b/lib/Plack/Client/Backend/http.pm
@@ -0,0 +1,28 @@
+package Plack::Client::Backend::http;
+use strict;
+use warnings;
+
+use Plack::App::Proxy;
+
+sub new {
+ my $class = shift;
+ my %params = @_;
+
+ bless {
+ proxy => Plack::App::Proxy->new->to_app,
+ }, $class;
+}
+
+sub proxy { shift->{proxy} }
+
+sub app_from_req {
+ my $self = shift;
+ my ($req) = @_;
+
+ my $uri = $req->uri->clone;
+ $uri->path('/');
+ $req->env->{'plack.proxy.remote'} = $uri->as_string;
+ return $self->proxy;
+}
+
+1;