} =~ s{/+/$}{/};
}
my $root = ($conf->{prefix} || '/');
my $path = $conf->{path} || 'jsonrpc';
my $r = $app->routes;
if ($conf->{controller}){
$r->any($root.$path)->to(
us';
use MyJsonRpcController;
sub startup {
my $self = shift;
$self->plugin('qooxdoo',{
prefix => '/',
path => 'jsonrpc',
controller => 'my_json_rpc_conroll
er'
});
}
=head1 DESCRIPTION
To deal with incoming JSON-RPC requests, write a controller using L<Mojolicious::Plugin::Qooxdoo::JsonRpcController>
as a parent, instead of the normal L<Mojolicio
package Mojolicious::Plugin::Qooxdoo::JsonRpcController;
use strict;
use warnings;
use Mojo::JSON qw(encode_json decode_json);
use Mojo::Base 'Mojolicious::Controller';
use Mojo::Promise;
use Storab
# Data comes as JSON object, so fetch a reference to it
my $type = $self->req->headers->content_type//'*missing header*';
if ($type !~ m{^application/json\b}i) {
application/json)");
$self->render(text => "invalid payload format announcement", status=>500);
return;
}
$data = eval { decode_json($self->req-