trict;
use warnings;
use 5.010;
use Carp;
use autodie;
use utf8;
use Moo;
use HTTP::Request;
use JSON;
use Net::HTTP::Spore;
use List::Util qw/first/;
use Scalar::Util qw/blessed weaken/;
use Data::U
default => sub { File::ShareDir::dist_file('WebService-Zaqar', 'marconi.spore.json') });
has 'client_uuid' => (is => 'ro',
lazy => 1,
bu
payloads serialized/deserialized to/from JSON -- except if
# you're receiving 401 or 403
$client->enable('+WebService::Zaqar::Middleware::Format::JSONSometimes');
# set X-Auth-Token heade
rmat::JSONSometimes;
# ABSTRACT: middleware for JSON format
use JSON;
use Moose;
extends 'Net::HTTP::Spore::Middleware::Format';
has _json_parser => (
is => 'rw',
isa => 'JSON',
lazy => 1,
default => sub { JSON->new->utf8(1)->allow_nonref },
);
sub encode { $_[0]->_json_parser->encode( $_[1] ); }
sub decode { $_[0]->_json_parser->decode( $_[1] ); }
sub acc
ept_type { ( 'Accept' => 'application/json' ) }
sub content_type { ( 'Content-Type' => 'application/json;' ) }
sub should_serialize {
my $self = shift;
$self->_check_serializer( shift->env,