Skip to content

Instantly share code, notes, and snippets.

@hdp
Created January 24, 2011 17:33
Show Gist options
  • Save hdp/793575 to your computer and use it in GitHub Desktop.
Save hdp/793575 to your computer and use it in GitHub Desktop.
$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