Command line client for json rpc
You can install it from AUR
Requirements:
git clone https://github.com/DizoftTeam/drpc.git
cd drpc
go build -o drpc main.go
# For all users
sudo ln -s /home/<user>/path/to/drpc /usr/local/bin/drpc
- Add file config support
Example of config
Note: in this config we are using yaml override cause it usability
_notify: ¬ify
name: _override_name
url: http://api.gvozdika.dizoft.ru/rpc
method: _override_method
params: { }
headers: { }
_base: &base
<<: *notify
id: 1
requests:
# Авторизация
- <<: *base
name: login
method: v1.users.login
params:
login: test
password: test
# Выход из системы
- <<: *base
name: logout
method: v1.users.logout
params:
token: $token # Require from cmd
Syntax is
drpc -file=DrpcFileConfig.yaml some_method_name [someParamName=someParamValue]
It means that you should provide this argument in command line!
drpc -file=drpc.yaml logout token=SomeTokenHere
- Show response headers by
-v
or-verbose
- Show spent time for request
- Fixed empty response of nil (server is down as example)
drpc request 1 http://localhost -method=v1.refs.list -v
Example of response
--->
{}
---
{
"id": ,
"jsonrpc": "2.0",
"method": "v1.refs.list",
"params": {}
}
<---
Time: 61ms
[Connection] keep-alive
[X-Powered-By] PHP/7.4.12
[Access-Control-Allow-Credentials] true
[X-Debug-Tag] 5fb27bdf00a24
[Vary] Accept-Encoding
[Server] nginx/1.18.0
[Access-Control-Expose-Headers]
[X-Debug-Duration] 44
[X-Debug-Link] /debug/default/view?tag=5fb27bdf00a24
[Date] Mon, 16 Nov 2020 13:17:19 GMT
[Content-Type] application/json; charset=UTF-8
---
{
"id": 1,
"jsonrpc": "2.0",
"result": []
}
- Send request with headers
drpc request 1 http://localhost -headers='{"X-User-Token": "<guid>"}' -method=users.login -params='{"login": "user", "password": "admin"}'
drpc -url='http://localhost:8089' -method='version' -params='{}' -id=1
- Отправка запроса и получение заголовков
-v - verbose
drpcclient request -v 1 http://localhost -headers='{"X-User-Token": "<guid>"}' -method=users.login -params='{"login": "user", "password": "admin"}'
- Генерация
curl
запроса
drpcclient curl 1 http://localhost -headers='{"X-User-Token": "<guid>"}' -method=users.login -params='{"login": "user", "password": "admin"}'