or die "Could not connect to Postgres: " . DBI->errstr;
my $cgi = CGI->new;
-my $post = $cgi->param('POSTDATA');
-my $ts = $cgi->http('X-Slack-Request-Timestamp');
-my $sig = $cgi->http('X-Slack-Signature');
+my $post;
+if ($#ARGV >= 0 && $ARGV[0] eq '--stdin') {
+ local $/ = undef;
+ $post = <STDIN>;
+} else {
+ $post = $cgi->param('POSTDATA');
+ my $ts = $cgi->http('X-Slack-Request-Timestamp');
+ my $sig = $cgi->http('X-Slack-Signature');
-my $digest = Digest::SHA::hmac_sha256_hex("v0:$ts:$post", $config::signing_secret);
-die "Failed signature" unless ($sig eq "v0=$digest");
+ my $digest = Digest::SHA::hmac_sha256_hex("v0:$ts:$post", $config::signing_secret);
+ die "Failed signature" unless ($sig eq "v0=$digest");
-print STDERR "JSON: $post\n";
+ print STDERR "JSON: $post\n";
+}
my $json = JSON::XS::decode_json($post);
if (exists($json->{'challenge'})) {