UR::Service::JsonRpcServer(3pm) | User Contributed Perl Documentation | UR::Service::JsonRpcServer(3pm) |
UR::Service::JsonRpcServer - A self-contained JSON-RPC server for UR namespaces
use lib '/path/to/your/moduletree'; use YourNamespace; my $rpc = UR::Service::JsonRpcServer->create(host => 'localhost', port => '8080', api_root => 'URapi', docroot => '/html/pages/path', ); $rpc->process();
This is a class containing an implementation of a JSON-RPC server to respond to requests involving UR-based namespaces and their objects. It uses Net::HTTPServer as the web server back-end library.
Incoming requests are divided into two major categories:
The constructor takes the following named parameters:
All other arguments are passed along to the Net::HTTPServer constructor.
There are (or will be) client-side code in both Perl and Javascript. The Perl code is (will be) implemented as a UR::Context layer that will return light-weight object instances containing only class info and IDs. All method calls will be serialized and sent over the wire for the server process to execute them.
The Javascript interface is defined in the file urinterface.js. An example:
var UR = new URInterface('http://localhost:8080/URApi/'); // Connect to the server var FooThingy = UR.get_class('Foo::Thingy'); // Get the class object for Foo::Thingy var thingy = FooThingy.get(1234); // Retrieve an instance with ID 1234 var result = thingy.call('method_name', 1, 2, 3); // Call $thingy->method_name(1,2,3) on the server
Ney::HTTPServer, urinterface.js
2022-01-17 | perl v5.32.1 |