Flea
(
F/FR/FRODWITH/Flea-0.04.tar.gz, FRODWITH, 2010;
MetaCPAN
)
;
use Exception::Class ('Flea::Pass' => { alias => 'pass' });
use Exporter::Declare '-magic';
use JSON;
use HTTP::Exception;
use Try::Tiny;
use Plack::Request;
use URI;
use List::Util qw(first);
defa
/$path")->canonical;
}
default_export json {
return [
200,
['Content-Type' => 'application/json; charset=UTF-8'],
[ JSON::encode_json(shift) ]
];
}
default_export htm
{
get '^/$' {
file 'index.html';
}
get '^/api$' {
json { foo => 'bar' };
}
post '^/resource/(\d+)$' {
my $request = request