RPC using Anything But XML (RABX) message parser and emitter
The RABX specification is a Perl module by mySociety.
Usage
require 'rabx/message'
Dump a RABX message:
RABX::Message.dump('R', 'RPC.method', ['argument', 3])
# => "R1:0,10:RPC.method,L1:2,T8:argument,I1:3,"
RABX::Message.dump('S', {name: 'foo', email: '[email protected]'})
# => "S1:0,A1:2,T4:name,T3:foo,T5:email,T15:[email protected],"
RABX::Message.dump('E', 404, 'Not Found')
# => "E1:0,3:404,9:Not Found,N"
Load a RABX message:
= RABX::Message.load("R1:0,10:RPC.method,L1:2,T8:argument,I1:3,")
.type # "R"
.method # "RPC.method"
.argumetns # ["argument", 3]
= RABX::Message.load("S1:0,A1:2,T4:name,T3:foo,T5:email,T15:[email protected],")
.type # "S"
.value # {"name"=>"foo", "email"=>"[email protected]"}
= RABX::Message.load("E1:0,3:404,9:Not Found,N")
.type # "E"
.code # "404"
.text # "Not Found"
.extra # nil
See the documentation to see how to work with RABX::Message
instances.
Notes
Generic RABX clients include:
- Perl
- PHP
- Python (REST interface)
- Ruby (REST interface)
- Command-line
mySociety has scripts to convert a Perl RABX server to a server-specific client in:
Copyright (c) 2014 James McKinney, released under the MIT license