istHub::Web::View::JSON;
use strict;
use base 'Catalyst::View::JSON';
use JSON::XS ();
__PACKAGE__->config(
allow_callback => 0,
expose_stash => 'json',
no_x_json_header => 1,
);
oder} = JSON::XS->new->latin1;
$self;
}
sub encode_json {
my ($self, $c, $data) = @_;
$self->{encoder}->encode($data);
}
=head1 NAME
App::HistHub::Web::View::JSON - Catalyst JSON View
=head1 SYNOPSIS
See L<App::HistHub::Web>
=head1 DESCRIPTION
Catalyst JSON View.
=head1 AUTHOR
Daisuke Murase
=head1 LICENSE
This library is free software, you can redistribute it and/or modify
c->res->status(500);
$c->stash->{json} = {
error => $last_error,
};
$c->error(0);
}
else {
$c->stash->{json} = {
result => $self->result
|| '',
error => $self->error || '',
};
}
$c->forward( $c->view('JSON') );
}
=head1 AUTHOR
Daisuke Murase
=head1 LICENSE
This library is free software, you can redist
SION = '0.01';
use POE qw/
Wheel::FollowTail
Component::Client::HTTPDeferred
/;
use JSON::XS ();
use HTTP::Request::Common;
use Fcntl ':flock';
has hist_file => (
is => 'rw',
Client::HTTPDeferred->new;
},
);
has json_driver => (
is => 'rw',
isa => 'JSON::XS',
lazy => 1,
default => sub {
JSON::XS->new->latin1;
},
);
has poll_del
session, $data) = @_;
my $json = $self->json_driver->decode($data);
if ($json->{error}) {
warn 'api poll error: '. $json->{error};
}
elsif ($json->{result}) {
$self->{