summaryrefslogtreecommitdiffstats
path: root/lib/Plack/Client/Backend/http.pm
blob: b8ca4289711068c86f883268b9cfc8fa6fd32bdf (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;