ght implementation of Spore specification
use Moo;
use Sub::Install;
use Try::Tiny;
use Carp;
use JSON::MaybeXS;
use Data::Rx;
use LWP::UserAgent;
use URI;
use File::ShareDir ':ALL';
use Subclass::Of;
d => 1,
coerce => sub {
my $json_spec = $_[0];
my $spec;
# it could be a file
try {
open my $fh, '<', $json_spec or croak 'Cannot read the spec file'
spec = decode_json(<$fh>);
close $fh;
}
catch {
try {
$spec = decode_json($json_spec);
}
# it is not json, so we are re
;
my $response = Net::HTTP::Knork::Response->new(
200, ['Content-Type', 'application/json'], '{"foo":1}';
);
$response->request($request);
=head1 DESCRIPTION
Net::HTTP::Knork::R
hen the body is sets for the first time.
=item content_type
$res->content_type('application/json');
my $ct = $res->content_type;
Gets or sets the content type of the response body
=item co
ype' => 'application/json']);
Gets or sets HTTP response headers.
=item header
my $cl = $res->header('Content-Length');
$res->header('Content-Type' => 'application/json');
Shortcut for C<<