mirror of
https://github.com/urbit/shrub.git
synced 2024-12-20 01:01:37 +03:00
json-rpc: add response-to-json
This commit is contained in:
parent
afd3c9b85e
commit
0c704bb145
@ -1,7 +1,7 @@
|
|||||||
:: Azimuth RPC API
|
:: Azimuth RPC API
|
||||||
::
|
::
|
||||||
/- rpc=json-rpc
|
/- rpc=json-rpc
|
||||||
/+ naive, *server, default-agent, verb, dbug, version
|
/+ naive, json-rpc, *server, default-agent, verb, dbug, version
|
||||||
|%
|
|%
|
||||||
+$ card card:agent:gall
|
+$ card card:agent:gall
|
||||||
::
|
::
|
||||||
@ -141,7 +141,7 @@
|
|||||||
++ get-point
|
++ get-point
|
||||||
|= [id=@t params=request-params:rpc]
|
|= [id=@t params=request-params:rpc]
|
||||||
%- json-response:gen
|
%- json-response:gen
|
||||||
%- rpc-response-to-json
|
%- response-to-json:json-rpc
|
||||||
?. ?=([%object *] params)
|
?. ?=([%object *] params)
|
||||||
[%error id 'X' 'RPC params must be an object']
|
[%error id 'X' 'RPC params must be an object']
|
||||||
?> ?=(^ +.params)
|
?> ?=(^ +.params)
|
||||||
@ -204,29 +204,6 @@
|
|||||||
['nonce' (numb:enjs:format nonce)]
|
['nonce' (numb:enjs:format nonce)]
|
||||||
==
|
==
|
||||||
--
|
--
|
||||||
:: TODO: move to rpc library
|
|
||||||
::
|
|
||||||
++ rpc-response-to-json
|
|
||||||
|= =response:rpc
|
|
||||||
^- json
|
|
||||||
:: TODO: consider all cases
|
|
||||||
::
|
|
||||||
?+ -.response ~|([%unsupported-rpc-response response] !!)
|
|
||||||
%result
|
|
||||||
:- %o
|
|
||||||
%- molt
|
|
||||||
^- (list [@t json])
|
|
||||||
~[['id' s+id.response] ['res' res.response]]
|
|
||||||
::
|
|
||||||
%error
|
|
||||||
:- %o
|
|
||||||
%- molt
|
|
||||||
^- (list [@t json])
|
|
||||||
:~ ['id' s+id.response]
|
|
||||||
['code' s+code.response]
|
|
||||||
['message' s+message.response]
|
|
||||||
==
|
|
||||||
==
|
|
||||||
--
|
--
|
||||||
::
|
::
|
||||||
++ scry-point
|
++ scry-point
|
||||||
|
@ -28,4 +28,26 @@
|
|||||||
%object [%o (~(gas by *(map @t json)) +.params)]
|
%object [%o (~(gas by *(map @t json)) +.params)]
|
||||||
==
|
==
|
||||||
==
|
==
|
||||||
|
::
|
||||||
|
++ response-to-json
|
||||||
|
|= =response
|
||||||
|
^- json
|
||||||
|
:: TODO: consider all cases
|
||||||
|
::
|
||||||
|
?+ -.response ~|([%unsupported-rpc-response response] !!)
|
||||||
|
%result
|
||||||
|
:- %o
|
||||||
|
%- molt
|
||||||
|
^- (list [@t json])
|
||||||
|
~[['id' s+id.response] ['res' res.response]]
|
||||||
|
::
|
||||||
|
%error
|
||||||
|
:- %o
|
||||||
|
%- molt
|
||||||
|
^- (list [@t json])
|
||||||
|
:~ ['id' s+id.response]
|
||||||
|
['code' s+code.response]
|
||||||
|
['message' s+message.response]
|
||||||
|
==
|
||||||
|
==
|
||||||
--
|
--
|
||||||
|
Loading…
Reference in New Issue
Block a user