Created
January 14, 2011 04:48
-
-
Save leedo/779184 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Plack::Builder; | |
my $old_app = sub { | |
return sub { | |
my $respond = shift; | |
$respond->([200, [], ['success']]); | |
} | |
}; | |
sub delayed_auth { | |
my ($env, $cb) = @_; | |
# ... AE::DBI query | |
$cb->(1); | |
} | |
sub { | |
my $env = shift; | |
return sub { | |
my $respond = shift; | |
delayed_auth($env, sub { | |
my $success = shift; | |
$respond->($success ? $old_app->($env) : [401, [], []]); | |
}); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment