Created
January 24, 2011 17:33
-
-
Save hdp/793575 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$app = ...; | |
if (my $map = $self->config->proxy_map) { | |
my $urlmap = Plack::App::URLMap->new; | |
for my $type (keys %$map) { | |
my ($prefix, $remote, $headers) = | |
@{$map->{$type}}{qw(path_prefix remote headers)}; | |
$headers ||= {}; | |
my $proxy = Plack::App::Proxy->new( | |
remote => $remote, | |
preserve_host_header => 1, | |
)->to_app; | |
$urlmap->mount($prefix => sub { | |
my $env = shift; | |
return $proxy->({ %$env, %$headers }); | |
}); | |
} | |
$urlmap->mount('/' => $app); | |
$app = $urlmap->to_app; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment