urbit/pkg/arvo/mar/json/rpc/response.hoon

44 lines
987 B
Plaintext
Raw Normal View History

::
/- *json-rpc
::
|_ res=response
::
++ grad %noun
++ grow
|%
++ noun res
--
++ grab :: convert from
|%
++ noun response :: from noun
2018-10-30 21:41:35 +03:00
++ httr :: from httr
|= hit=httr:eyre
2018-10-30 21:41:35 +03:00
^- response
~| hit
?: ?=(%2 (div p.hit 100))
2018-10-30 21:41:35 +03:00
=, html
%- json
?~ r.hit
a+~
(need (de-json q:u.r.hit))
2018-10-30 21:41:35 +03:00
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)
--
--