hiss/sigh typed http requests

This commit is contained in:
Anton Dyudin 2015-05-27 15:34:01 -07:00
parent 6450ed4ca1
commit f2e0911933
8 changed files with 141 additions and 5 deletions

11
base/ape/curl/core.hook Normal file
View File

@ -0,0 +1,11 @@
/+ mean
!:
::::
::
|_ [^ ~]
++ poke |*([[a=@ @] b=[mark *]] :_(+> [a %hiss / %wain b]~))
::++ poke-purl |=([[a=@ @] b=purl] :_(+> [a %hiss / %wain %purl b]~))
++ poke-noun |=([a=from b=tape] (poke a %purl (scan b auri:epur)))
++ sigh-wain |=([^ a=wain] ~&(a `+>))
++ sigh-tang |=([^ a=tang] `_+>`(mean a))
--

View File

@ -16,6 +16,7 @@
== == ::
$: %e :: to self
$% [%this p=? q=clip r=httq] :: proxied request
[%meta vase:,[%them (unit httr)]] :: type check
== == ::
$: %f :: to %ford
$% [%exec p=@p q=beak r=(unit silk)] ::
@ -53,6 +54,8 @@
$% [%at p=hole q=whir] :: authenticated
[%ay p=span:ship q=span:,@uvH ~] :: remote duct
[%he p=whir] :: HEAD request
[%hi p=mark ~] :: outbound HTTP
[%si ~] :: response done
[%of p=ixor q=$|(~ whir-of)] :: associated view
[%on p=span:,@uvH ~] :: dependency
[%to p=ixor q=span:ship r=term s=wire] :: associated app
@ -478,6 +481,20 @@
q.ask (~(put by q.ask) p.ask hen u.p.kyz)
kes (~(put by kes) hen p.ask)
==
::
%hiss :: outbound cage
::?~ p.kyz :: XX cancel
:: =+ sud=(need (~(get by kes) hen))
:: %= +>.$
:: mow :_(mow [ged [%give %thus sud ~]])
:: q.ask (~(del by q.ask) sud)
:: kes (~(del by kes) hen)
:: ==
:: ~& eyre-them/(earn p.u.p.kyz)
%+ pass-note hi//[p.kyz]
?: ?=(%hiss p.q.kyz)
[%e %meta :(slop !>(%them) !>(~) q.q.kyz)]
(ford-req root-beak [%cast %hiss %done ~ q.kyz])
::
%they :: inbound response
=+ kas=(need (~(get by q.ask) p.kyz))
@ -539,8 +556,12 @@
::
%went +>.$
%thou
?> ?=([%ay ^] tee)
(ames-gram (slav %p p.tee) got/~ (slav %uv q.tee) |2.sih)
?+ -.tee !!
%ay (ames-gram (slav %p p.tee) got/~ (slav %uv q.tee) |2.sih)
%hi =+ cay=[%httr !>(`httr`p.sih)]
?: ?=(%httr p.tee) (give-sigh ~ cay)
(pass-note si/~ (ford-req root-beak [%cast p.tee %done `cay]))
==
::
%unto :: XX horrible
=+ cuf=`cuft`+>.sih
@ -582,6 +603,13 @@
|- ^+ ..axon
?- tee
[?(%on %ay) *] ~|(e/ford/lost/-.tee !!)
[%si ~] (give-sigh q.sih)
[%hi ^]
?: ?=(%| -.q.sih)
(give-sigh q.sih) :: XX crash?
=* cay p.q.sih
?> ?=(%hiss p.cay)
(pass-note tee [%e %meta :(slop !>(%them) !>(~) q.cay)])
[%he *] :: XX hack
=. ..axon $(tee p.tee)
%_ ..axon
@ -696,6 +724,12 @@
+>(ded (~(del in ded) hen))
+>(mow :_(mow [hen %give %thou hit]))
::
++ give-sigh :: userspace done
|= res=(each cage tang)
=- +>.$(mow :_(mow [hen %give %sigh `cage`-]))
?. ?=(%| -.res) p.res
[%tang !>(p.res)]
::
++ mean-json |=([sas=@uG err=ares] (give-json sas ~ (ares-to-json err)))
++ nice-json |=(* (give-json 200 ~ (joba %ok %b &)))
::

View File

@ -22,6 +22,7 @@
++ cote :: ++ap note
$% [%meta p=@tas q=vase] ::
[%send p=ship q=cush] ::
[%hiss p=mark q=cage]
== ::
++ cove (pair bone (mold cote cuft)) :: internal move
++ move ,[p=duct q=(mold note-arvo gift-arvo)] :: typed move
@ -366,7 +367,7 @@
++ mo-cook :: take in /use
|= [pax=path hin=(hypo sign-arvo)]
^+ +>
?. ?=([@ @ ?(%inn %out) *] pax)
?. ?=([@ @ ?(%inn %out %enn) *] pax)
~& [%mo-cook-bad-pax pax]
!!
=+ dap=`@tas`i.pax
@ -374,7 +375,13 @@
=+ pap=(ap-abed:ap dap pry)
=+ vax=(slot 3 `vase`hin)
?- i.t.t.pax
%inn ap-abet:(ap-pour:pap t.t.t.pax (slot 3 `vase`hin))
%inn ap-abet:(ap-pour:pap t.t.t.pax (slot 3 `vase`hin))
%enn ?. ?=([%e %sigh *] q.hin)
~& [%mo-cook-weird q.hin]
~& [%mo-cook-weird-path pax]
+>.$
ap-abet:(ap-sigh:pap t.t.t.pax +>.q.hin)
::
%out ?. ?=([%g %unto *] q.hin)
~& [%mo-cook-weird q.hin]
~& [%mo-cook-weird-path pax]
@ -506,6 +513,7 @@
%pass
:+ %pass `path`[%use dap p.q.cov]
?- -.q.q.cov
%hiss `note-arvo`[%e %hiss p.q.q.cov q.q.q.cov]
%send `note-arvo`[%g %deal [our p.q.q.cov] q.q.q.cov]
%meta `note-arvo`[`@tas`p.q.q.cov %meta `vase`q.q.q.cov]
==
@ -643,6 +651,7 @@
?+ +<.q.vax
(ap-move-pass -.q.vax +<.q.vax cav)
%diff (ap-move-diff -.q.vax cav)
%hiss (ap-move-hiss -.q.vax cav)
%peer (ap-move-peer -.q.vax cav)
%pull (ap-move-pull -.q.vax cav)
%poke (ap-move-poke -.q.vax cav)
@ -664,6 +673,21 @@
[%| (ap-suck "move: improper diff")]
[%& sto %give %diff `cage`[-.q.vax (slot 3 (spec vax))]]
::
++ ap-move-hiss :: pass %hiss
|= [sto=bone vax=vase]
^- (each cove tang)
?. &(?=([p=* q=@ q=^] q.vax) ((sane %tas) q.q.vax))
[%| (ap-suck "move: malformed hiss ask.[%hiss path mark cage]")]
=+ gaw=(slot 7 vax)
?. &(?=([p=@ q=^] q.gaw) ((sane %tas) p.q.gaw))
[%| (ap-suck "move: malformed cage")]
=+ pux=((soft path) p.q.vax)
?. &(?=(^ pux) (levy u.pux (sane %ta)))
[%| (ap-suck "move: malformed path")]
:^ %& sto %pass
:- [(scot %p q.q.pry) %enn u.pux]
[%hiss q.q.vax [p.q.gaw (slot 3 (spec gaw))]]
::
++ ap-move-mess :: extract path, target
|= vax=vase
^- (each (trel path ship term) tang)
@ -807,7 +831,8 @@
^+ +>
=+ cug=(ap-find /lame)
?~ cug
~& [%ap-lame wut why]
=. why (turn why |=(a=tank rose/[~ "! " ~]^[a]~))
~> %slog.`rose/[" " "[" "]"]^[>%ap-lame< >wut< why]
+>.$
=^ cam +>.$
%+ ap-call q.u.cug
@ -832,6 +857,22 @@
?^ cam (ap-lame -.q.vax u.cam)
+>.$
::
++ ap-sigh :: http response
|= [pax=path cag=cage]
^+ +>
=. q.cag (spec q.cag)
=+ cug=(ap-find [%sigh p.cag pax])
?~ cug
(ap-lame %sigh (ap-suck "sigh: no {<`path`[p.cag pax]>}"))
=+ ^= arg ^- vase
%- slop
?: =(0 p.u.cug)
[!>([`@ud`ost `@p`q.q.pry `path`pax]) !>(cag)]
[!>([`@ud`ost `@p`q.q.pry (slag (dec p.u.cug) `path`pax)]) q.cag]
=^ cam +>.$ (ap-call q.u.cug arg)
?^ cam (ap-lame q.u.cug u.cam)
+>.$
::
++ ap-pout :: specific take
|= [pax=path cuf=cuft]
^+ +>
@ -986,6 +1027,7 @@
%merg `%c
%plug `%c
%them `%e
%hiss `%e
%want `%a
==
--

View File

@ -2418,6 +2418,7 @@
++ kiss-eyre :: in request ->$
$% [%born ~] :: new unix process
[%crud p=@tas q=(list tank)] :: XX rethink
[%hiss p=mark q=cage] :: outbound user req
[%init p=@p] :: report install
[%them p=(unit hiss)] :: outbound request
[%they p=@ud q=httr] :: inbound response
@ -2428,6 +2429,7 @@
== ::
++ gift-eyre :: out result <-$
$% [%mass p=mass] :: memory usage
[%sigh p=cage] :: marked http response
[%thou p=httr] :: raw http response
[%thus p=@ud q=(unit hiss)] :: http request/cancel
[%veer p=@ta q=path r=@t] :: drop-through

View File

@ -0,0 +1,9 @@
::
::::
::
/? 310
::
:::::
!:
|= [^ [arg=tape ~] ~]
purl/(scan arg auri:epur)

9
base/lib/mean/core.hook Normal file
View File

@ -0,0 +1,9 @@
|% ++ mean |=(a=tang (mean-wrap a |.(!!)))
++ mean-wrap
|* [a=tang _|?(**)]
^+ (+<+)
=> .(a `tang`a)
?~ a (+<+)
~> %mean.|.(i.a)
$(a t.a)
--

16
base/mar/httr/door.hook Normal file
View File

@ -0,0 +1,16 @@
::
:::: /hook/door/httr/mar
::
/? 314
|_ hit=httr
::
++ grow |% ++ wall (turn wain trip)
++ wain ~| hit
?> =(2 (div p.hit 100))
(lore q:(need r.hit))
--
++ grab :: convert from
|%
++ noun httr :: clam from %noun
--
--

13
base/mar/purl/door.hook Normal file
View File

@ -0,0 +1,13 @@
::
:::: /hook/door/purl/mar
::
/? 314
|_ url=purl
::
++ grow |% ++ hiss [url %get ~ ~]
--
++ grab :: convert from
|%
++ noun purl :: clam from %noun
--
--