rver;
use strict;
use warnings;
use AE;
use Data::Dumper;
use File::ShareDir;
use File::Spec;
use JSON::XS;
use HTTP::Request;
use LWP::UserAgent;
use Path::Class;
use Time::HiRes;
use Plack::App::Di
th, $req, $session);
$res ||= Plack::Response->new( 200, [ 'Content-Type' => 'application/json' ], '{msg:"ok"}' );
} elsif ($apiurl && $req->uri->path =~ /$apiurl/) {
# ajax reque
quest}->{requests} ];
$current->{pop_tap_request}->{cv}->send(
$self->json_response($stack)
);
}
} else {
# ajax request?
my $path =
s'
}
The return value can be any Perl construct. If it's a reference, the return value will be JSON encoded. Otherwise it will be passed as-is.
The C<server_api()> function takes the following par
文字列でも構いません。オブジェクトの場合は L<JSON::XS> にて JSON encode された結果が戻ります。
JSON::XS が使われるのが嫌な場合には、自前で文字列
en => $server->auto_open,
)
);
}
package JSTAPd::Server::Contents::contents;
use JSON::XS ();
sub AUTOLOAD {
my($class, $server, $req, $session, $args) = @_;
my $path = our $
if (ref($ret)) {
return Plack::Response->new(200, [ 'Content-Type' => 'application/json' ], JSON::XS->new->ascii->encode($ret) );
} else {
return Plack::Response->new(200, [ 'Co