blob: e4433854821f9848dfca711f2e440ea89b51d219 (
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
package Plack::Client::Backend::http;
use strict;
use warnings;
# ABSTRACT: backend for handling HTTP requests
use Plack::App::Proxy;
=head1 SYNOPSIS
Plack::Client->new(
'http' => {},
);
Plack::Client->new(
'http' => Plack::Client::Backend::http->new,
);
=head1 DESCRIPTION
This backend implements HTTP requests. The current implementation uses
L<Plack::App::Proxy> to make the request.
=cut
=method new
Constructor. Takes no arguments.
=cut
sub new {
my $class = shift;
my %params = @_;
bless {
proxy => Plack::App::Proxy->new->to_app,
}, $class;
}
sub _proxy { shift->{proxy} }
=method app_from_request
Takes a L<Plack::Request> object, and returns an app which will retrieve the
HTTP resource.
=cut
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;
|