Happy !

MasashiUmezawa / LtJsonRpc

Project infos

License MIT
Tags rpc, json, json-rpc
Creation date 2015-08-05
Website

Monticello registration

About LtJsonRpc

Lightning JSON-RPC

LtJsonRpc is a lightweight JSON-RPC implementation. It only depends on Zinc and JSON packages.

You can quickly create JSON-RPC services in a few lines of code.

LtJsonRpc provides a handy way for controlling your pharo.image from a command-line tool (curl).

Server

responder := LtJsonRpcResponder default initialize.
responder addHandlerNamed: 'reverse' block: [:str | str reverse] .
responder addHandlerNamed: 'now' block: [DateAndTime now asString] .
responder server start.

Client (curl)

Requests

curl -H "Content-Type: application/json" http://localhost:16164/api/jsonrpc -d '{"jsonrpc": "2.0", "method": "reverse", "params": ["HELLO"], "id": 1}'
curl -H "Content-Type: application/json" http://localhost:16164/api/jsonrpc -d '{"jsonrpc": "2.0", "method": "now", "id": 2}'

Answers

{"id":1,"result":"OLLEH","jsonrpc":"2.0"}
{"id":2,"result":"2015-08-05T09:39:33.767513+09:00","jsonrpc":"2.0"}

Client(st)

client := LtJsonRpcClient new.
client call: 'now'.
client call: 'reverse' arguments: 'HELLO'