kamailio-jsonrpc-client
is a lightweight wrapper around kamailio's jsonrpcs module. It exposes a REST API endpoints which executes jsonrpc requests and returns the results.
#!substdef "!HTTP_PORT!8081!g"
tcp_accept_no_cl=yes
listen=tcp:127.0.0.1:HTTP_PORT
loadmodule "xhttp.so"
loadmodule "jsonrpcs.so"
modparam("jsonrpcs", "transport", 1)
event_route[xhttp:request] {
if ($Rp != "HTTP_PORT") {
xlog("L_WARN", "HTTP request received on $Rp from $si");
xhttp_reply("403", "Forbidden", "", "");
exit;
}
$var(x) = $(hu{url.path});
xlog("L_INFO", "received request [$hu] [$var(x)]");
if ($hu =~ "^/RPC") {
xlog("L_INFO", "jsonrpc dispatch [$hu] [$var(x)]");
jsonrpc_dispatch();
return;
}
xhttp_reply("404", "Not Found", "application/javascript", "{\"$var(y)\"}\n\r");
return;
}
curl http:https://localhost:8080/v1/htable/dump?table=mytable
curl -X POST 'http:https://localhost:8080/v1/htable/mytable?action=flush'
curl -X DELETE 'http:https://localhost:8080/v1/htable/mytable/mykey'
curl http:https://localhost:8080/v1/htable/mytable?key=mykey
curl -X POST -d '{"id":"test123","username": "test123", "domain": "testdomain", "auth_username": "user01", "auth_password": "pass01", "proxy": "sip:5.6.6.7;transport=tcp", "random_delay": 10}' http:https://localhost:8080/v1/uacreg/register
curl -X POST 'http:https://localhost:8080/v1/uacreg/unregister?domain=testdomain&username=test123'
curl http:https://localhost:8080/v1/uacreg/list
curl 'http:https://localhost:8080/v1/uacreg/list?domain=testdomain'
curl 'http:https://localhost:8080/v1/uacreg/list?domain=testdomain&username=test123'