Created
November 23, 2011 12:36
-
-
Save und3f/1388567 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
#!/usr/bin/env starman | |
use strict; | |
use warnings; | |
use v5.10; | |
use AnyEvent; | |
use AnyEvent::Redis; | |
use JSON::XS; | |
use Plack::Request; | |
# Ensure presence | |
use HTTP::Parser::XS; | |
use EV; | |
my $redis = AnyEvent::Redis->new; | |
sub app { | |
my $env = shift; | |
my $req = Plack::Request->new($env); | |
if ($req->path_info eq '/') { | |
return sub { | |
my $respond = shift; | |
my $w = $respond->([200, ['Content-Type' => 'text/plain']]); | |
my $tid = $req->param('tid'); | |
$redis->set( | |
$tid => encode_json({%{$req->parameters}}), | |
sub { | |
$w->write('SET!'); | |
undef $w; | |
} | |
); | |
} | |
} | |
[404, ['Content-Type' => 'text/plain'], ['Not found']]; | |
} | |
\&app; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment