Skip to content

Instantly share code, notes, and snippets.

@sugar84
Created May 22, 2012 09:12
Show Gist options
  • Save sugar84/2767755 to your computer and use it in GitHub Desktop.
Save sugar84/2767755 to your computer and use it in GitHub Desktop.
delayed response through psgi
use common::sense;
use AnyEvent::HTTP;
my $app = sub {
my $env = shift;
return sub {
my $respond = shift;
fetch_content(sub {
my $content = shift;
return $respond->([ 200,
['Content-Type' => 'text/html'],
[$content]
]);
});
return;
};
};
sub fetch_content
{
my $cb = shift;
http_get("http://perldoc.perl.org", sub {
my ($data, $head) = @_;
$cb->($data);
return;
});
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment