shrub/pkg/arvo/mar/json/rpc/response.hoon
Jared Tobin b3901ab42f Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8'
git-subtree-dir: pkg/arvo
git-subtree-mainline: 9c8f40bf6c
git-subtree-split: c20e2a185f
2019-06-28 12:48:05 +08:00

39 lines
935 B
Plaintext

::
=, rpc:jstd
::
|_ res=response
::
++ grab :: convert from
|%
++ noun response :: from noun
++ httr :: from httr
|= hit/httr:eyre
^- response
~| hit
?: ?=($2 (div p.hit 100))
=, html
%- json
?~ r.hit
a+~
(need (de-json q:u.r.hit))
fail+hit
++ json :: from json
=, dejs-soft:format
|= a=json
^- response
=; dere
=+ res=((ar dere) a)
?~ res (need (dere a))
[%batch u.res]
|= a=json
^- (unit response)
=/ res=(unit [@t json])
::TODO breaks when no id present
((ot id+so result+some ~) a)
?^ res `[%result u.res]
~| a
:+ ~ %error %- need
((ot id+so error+(ot code+no message+so ~) ~) a)
--
--