|
NAMEPlack::App::Proxy - proxy requests SYNOPSIS use Plack::Builder;
# proxy all requests for /static to 127.0.0.1:80
builder {
mount "/static" => Plack::App::Proxy->new(remote => "http://127.0.0.1:80")->to_app;
};
# Call from other app
my $proxy = Plack::App::Proxy->new->to_app;
my $app = sub {
my $env = shift;
...
$env->{'plack.proxy.url'} = $url;
$proxy->($env);
};
DESCRIPTIONPlack::App::Proxy is a middleware-aware proxy application for Plack. OPTIONS
MIDDLEWARE CONFIGURATIONSThis application is just like a normal PSGI application and is middleware aware, which means you can modify proxy requests (and responses) using Plack middleware stack. It also supports the following special environment variables:
For example, the following builder code allows you to proxy all GET requests for .png paths to the lolcat image (yes, a silly example) but proxies to the internal host otherwise. my $mw = sub {
my $app = shift;
sub {
my $env = shift;
if ($env->{REQUEST_METHOD} eq 'GET' && $env->{PATH_INFO} =~ /\.png$/) {
$env->{'plack.proxy.url'} = 'http://lolcat.example.com/lol.png';
}
$app->($env);
};
};
use Plack::Builder;
builder {
enable $mw;
Plack::App::Proxy->new(remote => 'http://10.0.0.1:8080')->to_app;
};
AUTHORLee Aylward Masahiro Honma Tatsuhiko Miyagawa Jesse Luehrs LICENSEThis library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSOPlack::Builder
|