shrub/mar/json/rpc/response.hoon

37 lines
917 B
Plaintext
Raw Normal View History

::
/- json-rpc
=, json-rpc
::
|_ res=response
::
++ grab :: convert from
|%
++ noun response :: from noun
2018-10-30 21:41:35 +03:00
++ 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
2018-03-15 02:58:01 +03:00
=; dere
=+ res=((ar dere) a)
?~ res (need (dere a))
[%batch u.res]
|= a=json
^- (unit response)
=/ res=(unit [@t json])
2018-09-27 04:16:17 +03:00
::TODO breaks when no id present
((ot id+so result+some ~) a)
?^ res `[%result u.res]
2018-04-09 17:57:53 +03:00
~| a
2018-03-15 02:58:01 +03:00
:+ ~ %error %- need
2018-04-09 17:57:53 +03:00
((ot id+so error+(ot code+no message+so ~) ~) a)
--
--