mirror of
https://github.com/urbit/shrub.git
synced 2025-01-01 17:16:47 +03:00
launch: add /who endpoint
The /who endpoint responds with the name of the ship in JSON
This commit is contained in:
parent
069ec72f8a
commit
e16c999c76
@ -57,10 +57,14 @@
|
||||
|_ bol=bowl:gall
|
||||
+* this .
|
||||
def ~(. (default-agent this %|) bol)
|
||||
launch-who [%pass /who %arvo %e %serve [~ /who] q.byk.bol /gen/who/hoon ~]
|
||||
++ on-init
|
||||
^- (quip card _this)
|
||||
:_ this(state *[%2 state-two])
|
||||
[%pass / %arvo %e %connect [~ /] %launch]~
|
||||
:~
|
||||
launch-who
|
||||
[%pass / %arvo %e %connect [~ /] %launch]
|
||||
==
|
||||
::
|
||||
++ on-save !>(state)
|
||||
::
|
||||
@ -68,6 +72,7 @@
|
||||
|= old=vase
|
||||
^- (quip card _this)
|
||||
=/ old-state !<(versioned-state old)
|
||||
=| cards=(list card)
|
||||
|-
|
||||
?- -.old-state
|
||||
%0
|
||||
@ -80,9 +85,9 @@
|
||||
(~(del by path-to-tile.old-state) /primary)
|
||||
first-time.old-state
|
||||
==
|
||||
$(old-state [%2 new-state])
|
||||
$(old-state [%2 new-state], cards [launch-who cards])
|
||||
::
|
||||
%2 [~ this(state old-state)]
|
||||
%2 [(flop cards) this(state old-state)]
|
||||
==
|
||||
::
|
||||
++ on-poke
|
||||
|
22
pkg/arvo/gen/who.hoon
Normal file
22
pkg/arvo/gen/who.hoon
Normal file
@ -0,0 +1,22 @@
|
||||
/+ *server
|
||||
:: @p request handler
|
||||
::
|
||||
|= [[now=@da eny=@ bek=beak] ~ ~]
|
||||
|= [authorized=? =request:http]
|
||||
^- simple-payload:http
|
||||
=/ url=(unit pork:eyre)
|
||||
(rush url.request apat:de-purl:html)
|
||||
::
|
||||
:: url doesn't match expected binding from :launch
|
||||
::
|
||||
?. ?=(^ url)
|
||||
~| [%invalid-url url.request] !!
|
||||
?. ?=([%who *] q.u.url)
|
||||
~| [%unknown-url url.request] !!
|
||||
::
|
||||
::
|
||||
?. ?=(~ t.q.u.url)
|
||||
[[%404 ~] ~]
|
||||
=/ response=json
|
||||
(frond:enjs:format %who (ship:enjs:format p.bek))
|
||||
(json-response:gen (json-to-octs response))
|
Loading…
Reference in New Issue
Block a user