summaryrefslogtreecommitdiffstats
path: root/lib/Plack/Client/Backend/http.pm
blob: f57ee1f7942b00e2b1a3b99280b833f22e6d6568 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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_request {
    my $self = shift;
    my ($req) = @_;

    my $uri = $req->uri->clone;
    $uri->path('/');
    $req->env->{'plack.proxy.remote'} = $uri->as_string;
    return $self->_proxy;
}

1;