CallBackery
view release on metacpan or search on metacpan
lib/CallBackery/Controller/RpcService.pm view on Meta::CPAN
package CallBackery::Controller::RpcService;
use Mojo::Base qw(Mojolicious::Plugin::Qooxdoo::JsonRpcController),
-signatures,-async_await;
use CallBackery::Exception qw(mkerror);
use CallBackery::Translate qw(trm);
use Mojo::JSON qw(encode_json decode_json from_json);
use Syntax::Keyword::Try;
use Scalar::Util qw(blessed weaken);
=head1 NAME
CallBackery::RpcService - RPC services for CallBackery
=head1 SYNOPSIS
This module gets instantiated by L<CallBackery> and provides backend
functionality.
=head1 DESCRIPTION
This module provides the following methods
=cut
# the name of the service we provide
has service => 'default';
=head2 allow_rpc_access(method)
is this method accessible?
=cut
my %allow = (
getBaseConfig => 1,
login => 1,
logout => 1,
ping => 1,
getUserConfig => 2,
getPluginConfig => 3,
validatePluginData => 3,
processPluginData => 3,
getPluginData => 3,
getSessionCookie => 2
);
has config => sub ($self) {
$self->app->config;
}, weak => 1;
has user => sub ($self) {
my $obj = $self->app->userObject->new(app=>$self->app,controller=>$self,log=>$self->log);
return $obj;
};
has pluginMap => sub ($self) {
my $map = $self->config->cfgHash->{PLUGIN};
return $map;
}, weak => 1;
sub allow_rpc_access ($self,$method) {
if (not $self->req->method eq 'POST') {
# sorry we do not allow GET requests
$self->log->error("refused ".$self->req->method." request");
return 0;
}
if (not exists $allow{$method}){
( run in 0.524 second using v1.01-cache-2.11-cpan-39bf76dae61 )