Skip to content

Instantly share code, notes, and snippets.

@hatak
Created August 7, 2012 09:08
Show Gist options
  • Save hatak/3283591 to your computer and use it in GitHub Desktop.
Save hatak/3283591 to your computer and use it in GitHub Desktop.
Simple server returns the json response
use JSON;
use Plack::Request;
my $app = sub {
my $req = Plack::Request->new(shift);
my $res = $req->new_response(200);
$res->content_type('application/json');
$res->body(encode_json(+{
method => $req->method,
query_strings => $req->query_parameters->as_hashref,
body_parameters => $req->body_parameters->as_hashref,
message => 'Hello JSON World!',
}));
return $res->finalize;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment