2021-05-11 14:28:26 +03:00
|
|
|
:: Azimuth JSON-RPC API
|
2021-04-25 16:37:40 +03:00
|
|
|
::
|
2021-07-13 16:21:24 +03:00
|
|
|
/- rpc=json-rpc
|
2021-04-29 12:14:32 +03:00
|
|
|
/+ naive,
|
2021-08-16 14:01:23 +03:00
|
|
|
azimuth-roll-rpc,
|
2021-04-29 12:14:32 +03:00
|
|
|
json-rpc,
|
|
|
|
*server,
|
|
|
|
default-agent,
|
|
|
|
verb,
|
|
|
|
dbug,
|
2021-04-29 13:10:58 +03:00
|
|
|
agentio
|
2021-04-25 16:37:40 +03:00
|
|
|
|%
|
2021-05-11 14:28:26 +03:00
|
|
|
::
|
2021-04-25 16:37:40 +03:00
|
|
|
+$ card card:agent:gall
|
|
|
|
::
|
|
|
|
+$ state-0 [%0 ~]
|
|
|
|
--
|
|
|
|
::
|
|
|
|
%+ verb |
|
|
|
|
%- agent:dbug
|
|
|
|
::
|
|
|
|
=| state-0
|
2021-05-21 13:34:29 +03:00
|
|
|
=* state -
|
2021-04-25 16:37:40 +03:00
|
|
|
::
|
|
|
|
^- agent:gall
|
|
|
|
=<
|
|
|
|
|_ =bowl:gall
|
|
|
|
+* this .
|
|
|
|
do ~(. +> bowl)
|
|
|
|
def ~(. (default-agent this %|) bowl)
|
|
|
|
::
|
|
|
|
++ on-init
|
|
|
|
^- (quip card _this)
|
|
|
|
~& > 'init'
|
|
|
|
:_ this
|
2021-05-21 13:28:54 +03:00
|
|
|
[%pass /bind %arvo %e %connect [~ /v1/azimuth] dap.bowl]~
|
2021-04-25 16:37:40 +03:00
|
|
|
::
|
|
|
|
++ on-save !>(state)
|
|
|
|
++ on-load
|
|
|
|
|= old=vase
|
|
|
|
^- (quip card _this)
|
|
|
|
[~ this(state !<(state-0 old))]
|
|
|
|
::
|
|
|
|
++ on-poke
|
|
|
|
|= [=mark =vase]
|
|
|
|
^- (quip card _this)
|
|
|
|
|^
|
|
|
|
?> (team:title our.bowl src.bowl)
|
|
|
|
?+ mark (on-poke:def mark vase)
|
|
|
|
%handle-http-request
|
|
|
|
=+ !<([id=@ta req=inbound-request:eyre] vase)
|
|
|
|
:_ this
|
2021-05-03 14:35:21 +03:00
|
|
|
(handle-http-request id req)
|
2021-04-25 16:37:40 +03:00
|
|
|
::
|
|
|
|
%azimuth-action
|
|
|
|
=+ !<([%disconnect bind=binding:eyre] vase)
|
|
|
|
~& >>> "disconnecting at {<bind>}"
|
|
|
|
:_ this
|
2021-05-21 13:34:29 +03:00
|
|
|
[%pass /bind %arvo %e %disconnect bind]~
|
2021-04-25 16:37:40 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
++ handle-http-request
|
2021-05-03 14:35:21 +03:00
|
|
|
|= [id=@ta =inbound-request:eyre]
|
|
|
|
^- (list card)
|
2021-04-25 16:37:40 +03:00
|
|
|
|^
|
|
|
|
=* req request.inbound-request
|
|
|
|
=* headers header-list.req
|
|
|
|
=/ req-line (parse-request-line url.req)
|
|
|
|
?. =(method.req %'POST')
|
|
|
|
:: TODO: method not supported
|
|
|
|
::
|
2021-05-03 14:35:21 +03:00
|
|
|
(give-simple-payload:app id not-found:gen)
|
2021-07-13 16:21:24 +03:00
|
|
|
?~ rpc-request=(validate-request:json-rpc body.req)
|
2021-04-25 16:37:40 +03:00
|
|
|
:: TODO: malformed request
|
|
|
|
::
|
2021-05-03 14:35:21 +03:00
|
|
|
(give-simple-payload:app id not-found:gen)
|
2021-07-07 18:29:12 +03:00
|
|
|
=/ [data=(list cage) response=simple-payload:http]
|
2021-05-03 14:35:21 +03:00
|
|
|
(process-rpc-request:do u.rpc-request)
|
|
|
|
%+ weld
|
|
|
|
(give-simple-payload:app id response)
|
2021-07-07 18:29:12 +03:00
|
|
|
|-
|
2021-05-03 14:35:21 +03:00
|
|
|
?~ data ~
|
2021-07-07 18:29:12 +03:00
|
|
|
:_ $(data t.data)
|
2021-05-03 14:35:21 +03:00
|
|
|
^- card
|
2021-07-13 16:21:24 +03:00
|
|
|
[%pass / %agent [our.bowl %azimuth] %poke i.data]
|
2021-04-25 16:37:40 +03:00
|
|
|
--
|
|
|
|
--
|
|
|
|
::
|
|
|
|
++ on-watch
|
|
|
|
|= =path
|
|
|
|
^- (quip card _this)
|
|
|
|
?> (team:title our.bowl src.bowl)
|
|
|
|
?+ path (on-watch:def path)
|
|
|
|
[%http-response *] [~ this]
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ on-arvo
|
|
|
|
|= [=wire =sign-arvo]
|
|
|
|
^- (quip card _this)
|
|
|
|
?+ sign-arvo (on-arvo:def wire sign-arvo)
|
|
|
|
[%eyre %bound *]
|
|
|
|
~? !accepted.sign-arvo
|
|
|
|
[dap.bowl 'bind rejected!' binding.sign-arvo]
|
|
|
|
[~ this]
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ on-leave on-leave:def
|
|
|
|
++ on-peek on-peek:def
|
|
|
|
++ on-agent on-agent:def
|
|
|
|
++ on-fail on-fail:def
|
|
|
|
--
|
|
|
|
::
|
|
|
|
|_ =bowl:gall
|
|
|
|
++ process-rpc-request
|
2021-07-07 18:29:12 +03:00
|
|
|
|= req=batch-request:rpc
|
|
|
|
^- [(list cage) simple-payload:http]
|
|
|
|
|^
|
|
|
|
?- -.req
|
|
|
|
%o
|
|
|
|
=/ [data=(unit cage) =response:rpc]
|
|
|
|
(process p.req)
|
|
|
|
[(drop data) (render response)]
|
|
|
|
::
|
|
|
|
%a
|
|
|
|
=| data=(list cage)
|
|
|
|
=| resp=(list response:rpc)
|
|
|
|
|-
|
|
|
|
?~ p.req
|
|
|
|
[(flop data) (render %batch (flop resp))]
|
|
|
|
=/ [dat=(unit cage) res=response:rpc]
|
|
|
|
(process i.p.req)
|
|
|
|
=? data ?=(^ dat) [u.dat data]
|
|
|
|
$(p.req t.p.req, resp [res resp])
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ render
|
|
|
|
|= res=response:rpc
|
2021-04-25 16:37:40 +03:00
|
|
|
%- json-response:gen
|
2021-07-07 18:29:12 +03:00
|
|
|
(response-to-json:json-rpc res)
|
|
|
|
::
|
|
|
|
++ process
|
|
|
|
|= request:rpc
|
2021-08-16 14:01:23 +03:00
|
|
|
=, azimuth-roll-rpc
|
2021-07-07 18:29:12 +03:00
|
|
|
?. ?=([%map *] params)
|
|
|
|
[~ ~(parse error:json-rpc id)]
|
|
|
|
=/ method=@tas (enkebab method)
|
|
|
|
?+ method [~ ~(method error:json-rpc id)]
|
2021-09-05 13:36:19 +03:00
|
|
|
%get-point `(get-point id +.params point:scry)
|
|
|
|
%get-dns `(get-dns id +.params dns:scry)
|
|
|
|
%get-naive-state `(get-naive id +.params naive-state:scry)
|
2021-07-07 18:29:12 +03:00
|
|
|
==
|
|
|
|
--
|
2021-04-25 16:37:40 +03:00
|
|
|
::
|
2021-05-11 14:28:26 +03:00
|
|
|
++ scry
|
2021-05-06 14:20:13 +03:00
|
|
|
|%
|
2021-05-11 14:28:26 +03:00
|
|
|
++ point
|
|
|
|
|= =ship
|
2021-05-21 13:34:29 +03:00
|
|
|
.^ (unit point:naive)
|
|
|
|
%gx
|
2021-07-13 16:21:24 +03:00
|
|
|
(~(scry agentio bowl) %azimuth /point/(scot %p ship)/noun)
|
2021-05-11 14:28:26 +03:00
|
|
|
==
|
2021-06-29 08:45:44 +03:00
|
|
|
::
|
2021-06-28 14:01:04 +03:00
|
|
|
++ dns
|
|
|
|
.^ (list @t)
|
|
|
|
%gx
|
2021-08-16 14:01:23 +03:00
|
|
|
(~(scry agentio bowl) %azimuth /dns/noun)
|
2021-06-28 14:01:04 +03:00
|
|
|
==
|
2021-09-05 13:36:19 +03:00
|
|
|
::
|
|
|
|
++ naive-state
|
|
|
|
.^ ^state:naive
|
|
|
|
%gx
|
|
|
|
(~(scry agentio bowl) %azimuth /nas/noun)
|
|
|
|
==
|
2021-05-11 14:28:26 +03:00
|
|
|
--
|
2021-04-25 16:37:40 +03:00
|
|
|
--
|