mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-15 01:52:42 +03:00
115 lines
2.3 KiB
Plaintext
115 lines
2.3 KiB
Plaintext
/- lens
|
|
/+ *server
|
|
/= lens-mark /: /===/mar/lens/command
|
|
/!noun/
|
|
=, format
|
|
|%
|
|
:: +move: output effect
|
|
::
|
|
+$ move [bone card]
|
|
:: +card: output effect payload
|
|
::
|
|
+$ card
|
|
$% [%connect wire binding:eyre term]
|
|
[%http-response =http-event:http]
|
|
[%peel wire dock mark path]
|
|
[%poke wire dock poke]
|
|
[%pull wire dock ~]
|
|
==
|
|
::
|
|
+$ poke
|
|
$% [%lens-command command:lens]
|
|
==
|
|
::
|
|
+$ state
|
|
$% $: %0
|
|
job=(unit [=bone com=command:lens])
|
|
==
|
|
==
|
|
::
|
|
--
|
|
::
|
|
|_ [bow=bowl:gall state=state]
|
|
::
|
|
++ this .
|
|
::
|
|
++ prep
|
|
|= old=(unit *)
|
|
^- (quip move _this)
|
|
[~ this]
|
|
::
|
|
:: alerts us that we were bound. we need this because the vane calls back.
|
|
::
|
|
++ bound
|
|
|= [wir=wire success=? binding=binding:eyre]
|
|
^- (quip move _this)
|
|
[~ this]
|
|
::
|
|
++ poke-handle-http-request
|
|
%- (require-authorization:app ost.bow move this)
|
|
|= =inbound-request:eyre
|
|
^- (quip move _this)
|
|
?^ job.state
|
|
:_ this
|
|
[ost.bow %http-response %start [%500 ~] ~ %.y]~
|
|
::
|
|
=/ request-line (parse-request-line url.request.inbound-request)
|
|
=/ site (flop site.request-line)
|
|
::
|
|
=/ jon=json
|
|
(need (de-json:html q:(need body.request.inbound-request)))
|
|
=/ com=command:lens
|
|
(json:grab:lens-mark jon)
|
|
:_ this(job.state (some [ost.bow com]))
|
|
[ost.bow %peel /sole [our.bow %dojo] %lens-json /sole]~
|
|
::
|
|
++ diff-lens-json
|
|
|= [=wire jon=json]
|
|
^- (quip move _this)
|
|
?~ jon
|
|
[~ this]
|
|
?> ?=(^ job.state)
|
|
:_ this(job.state ~)
|
|
[bone.u.job.state %http-response (json-response:app (json-to-octs jon))]~
|
|
::
|
|
++ quit
|
|
|= =wire
|
|
^- (quip move _this)
|
|
~& [%quit wire]
|
|
[~ this]
|
|
::
|
|
++ reap
|
|
|= [=wire saw=(unit tang)]
|
|
^- (quip move _this)
|
|
?^ saw
|
|
[((slog u.saw) ~) this]
|
|
?> ?=(^ job.state)
|
|
:_ this
|
|
:~ [ost.bow %poke /sole [our.bow %dojo] %lens-command com.u.job.state]
|
|
[ost.bow %pull /sole [our.bow %dojo] ~]
|
|
==
|
|
::
|
|
++ coup
|
|
|= [=wire saw=(unit tang)]
|
|
^- (quip move _this)
|
|
?^ saw
|
|
[((slog u.saw) ~) this]
|
|
[~ this]
|
|
::
|
|
:: +poke-handle-http-cancel: received when a connection was killed
|
|
::
|
|
++ poke-handle-http-cancel
|
|
|= =inbound-request:eyre
|
|
^- (quip move _this)
|
|
:: the only long lived connections we keep state about are the stream ones.
|
|
::
|
|
[~ this]
|
|
::
|
|
++ poke-noun
|
|
|= a=*
|
|
^- (quip move _this)
|
|
~& poke+a
|
|
[~ this]
|
|
::
|
|
--
|