Created
May 22, 2012 09:12
-
-
Save sugar84/2767755 to your computer and use it in GitHub Desktop.
delayed response through psgi
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
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