Skip to content

Instantly share code, notes, and snippets.

@und3f
Created November 23, 2011 12:36
Show Gist options
  • Save und3f/1388567 to your computer and use it in GitHub Desktop.
Save und3f/1388567 to your computer and use it in GitHub Desktop.
#!/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