shrub/mar/json/rpc/response.hoon
Fang e7812c372a Remove deprecated json-rpc sur file
These now live in zuse, rpc:jstd.
2019-02-03 20:58:03 +01:00

36 lines
904 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 (need (de-json q:(need 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)
--
--