Table of Contents
List of Examples
pretty_format
parameterjsonrpc_dispatch
usagejsonrpc_exec
usageTable of Contents
This module provides a JSON-RPC server over HTTP implementation, tailored for the needs of Kamailio. It implements the Kamailio RPC interface over JSON-RPC.
The JSONRPC-S module uses the xHTTP module to handle HTTP requests. Read the documentation of the xHTTP module for more details.
This module does not implement asynchronous RPC commands. It is unlikely that asynchronous RPC commands will be executed from an JSON-RPC over HTTP client.
This module does not accept parameters embedded in a structure (see the RPC documentation for more info about how parameters can be passed to RPC).
Handle the JSONRPC request and generate a response.
Example 1.2. jsonrpc_dispatch
usage
... #!KAMAILIO memdbg=5 memlog=5 debug=3 log_stderror=yes fork=yes children=2 tcp_accept_no_cl=yes mpath="modules/" loadmodule "sl.so" loadmodule "pv.so" loadmodule "xhttp.so" loadmodule "jsonrpc-s.so" request_route { send_reply("404", "not found"); exit; } event_route[xhttp:request] { if(src_ip!=127.0.0.1) { xhttp_reply("403", "Forbidden", "text/html", "<html><body>Not allowed from $si</body></html>"); exit; } if ($hu =~ "^/RPC") { jsonrpc_dispatch(); } else { xhttp_reply("200", "OK", "text/html", "<html><body>Wrong URL $hu</body></html>"); } return; } ...
Execute a JSON-RPC command given as a parameter.
The parameter has to be a valid full JSON-RPC document. It can be a dynamic string with variables. The result of the command can be accessed via $jsonrpl(key) pseudo variables.
Example 1.3. jsonrpc_exec
usage
... jsonrpc_exec({"jsonrpc": "2.0", "method": "dispatcher.reload", "id": 1}'); ...