er = Router::Simple->new();
$router->connect('/', { controller => 'JSONRPC', action => 'call' }, {on_match => \&is_called_json_rpc});
$router->connect('/', { controller => 'Root', action => 'i
->{action}, $res);
} else {
return [ 404, [], ['not found'] ];
}
}
sub is_called_json_rpc {
my ($env, $match) = @_;
my $req = App::Donburi::Web::Request->new($env);
return
package App::Donburi::Web::C::JSONRPC;
use strict;
use warnings;
use parent 'App::Donburi::Web::C';
use JSON;
use App::Donburi::Util;
sub do_call {
my $self = shift;
my $method = $self->re
q->param('method');
my $params = JSON->new->utf8->decode($self->req->param('params') || {});
my $text = $params->{text};
my $channel = $params->{channel};
unless (
$method eq
error?
return [
500,
[ 'Content-Type' => 'application/json' ],
[ JSON->new->utf8->encode({ message => 'internal server error', code => 000 }) ]
];