diff --git a/app/hood.hoon b/app/hood.hoon index 2a9ae5537..755690657 100644 --- a/app/hood.hoon +++ b/app/hood.hoon @@ -226,4 +226,6 @@ ++ woot-helm (wrap take-woot):from-helm ++ writ-kiln-autoload (wrap take-writ-autoload):from-kiln ++ writ-kiln-sync (wrap take-writ-sync):from-kiln + +++ bound (wrap take-bound):from-helm -- diff --git a/gen/frontpage.hoon b/gen/frontpage.hoon index 3e60913d6..e650c9a47 100644 --- a/gen/frontpage.hoon +++ b/gen/frontpage.hoon @@ -2,10 +2,15 @@ :: :: outer gate is a standard generator :: -|= [bowl:gall base-path=[=desk =spur] $~] +|= [[now=@da eny=@ bek=beak] $~ $~] :: -:- %build -|= http-request +:: :- %build +|= [authorized=? http-request:light] +^- mime +:- ['text' 'html' ~] +%- as-octs:mimes:html +%- crip +%- en-xml:html ^- manx ;html ;head @@ -13,7 +18,7 @@ == ;body ;h1:"Ran generator" - ;p:"Executing on {<(scot %p our)>}." + :: ;p:"Executing on {<(scot %p our)>}." ;p:"The method was {<(trip method)>}." ;p:"The url was {<(trip url)>}." == diff --git a/gen/hood/serve.hoon b/gen/hood/serve.hoon index e704a1c8f..d091fcf9a 100644 --- a/gen/hood/serve.hoon +++ b/gen/hood/serve.hoon @@ -3,18 +3,13 @@ :::: /hoon/serve/hood/gen :: /? 310 -/+ old-zuse -=, old-zuse :: :::: :: :- %say +:: +:: TODO: dojo doesn't like the types? |= $: {now/@da eny/@uvJ bec/beak} - {{pax/$@(term {i/knot t/path}) ~} ~} + {{=binding:light =generator:light ~} ~} == -:- %helm-serve -?@ pax pax -=+ bem=(need (tome pax)) -?. =([%da now] r.bem) :: XX actual sentinel - bem -bem(r [%ud 0]) +[%helm-serve binding generator] diff --git a/lib/hood/helm.hoon b/lib/hood/helm.hoon index f5f2284cc..502d58483 100644 --- a/lib/hood/helm.hoon +++ b/lib/hood/helm.hoon @@ -51,7 +51,8 @@ {$flog wire flog:dill} :: {$funk wire @p @p @} :: {$nuke wire ship} :: - {$serv wire ?(desk beam)} :: + :: {$serv wire ?(desk beam)} :: + [%serve wire binding:light generator:light] :: {$poke wire dock pear} :: {$want wire sock path *} :: send message == :: @@ -111,9 +112,9 @@ %^ emit %poke /helm/ask/(scot %p ~socden-malzod) [[~socden-malzod %ask] %ask-mail mel] :: -++ poke-serve - |= top/?(desk beam) =< abet - (emit %serv /helm/serv top) +:: ++ poke-serve +:: |= top/?(desk beam) =< abet +:: (emit %serv /helm/serv top) :: ++ poke-hi |= mes/@t @@ -245,6 +246,14 @@ |= {way/wire her/ship cop/coop} =< abet (emit %flog ~ %text "woot: {<[way cop]>}") :: +++ poke-serve + |= [=binding:light =generator:light] =< abet + (emit %serve /helm/serv binding generator) +:: +++ take-bound + |= [wir=wire success=? binding=binding:light] =< abet + (emit %flog ~ %text "bound: {}") +:: ++ poke-tlon-init-stream :: creates stream channel and makes it pull from :: urbit-meta on {met}. diff --git a/mar/mime.hoon b/mar/mime.hoon index 7264a8e9e..9acc34741 100644 --- a/mar/mime.hoon +++ b/mar/mime.hoon @@ -11,7 +11,7 @@ :: ++ grab :: convert from |% - ++ noun mime :: clam from %noun + +$ noun mime :: clam from %noun ++ tape |=(a/_"" [/application/x-urb-unknown (as-octt:mimes:html a)]) -- diff --git a/sys/vane/gall.hoon b/sys/vane/gall.hoon index b6850758e..6947bf22f 100644 --- a/sys/vane/gall.hoon +++ b/sys/vane/gall.hoon @@ -1268,6 +1268,7 @@ $well `%e $wipe `%f %connect `%l + %serve `%l == -- -- diff --git a/sys/vane/light.hoon b/sys/vane/light.hoon index dc9dc5154..d67e2dd53 100644 --- a/sys/vane/light.hoon +++ b/sys/vane/light.hoon @@ -160,7 +160,7 @@ +$ action $% :: dispatch to a generator :: - [%gen generator=[=desk path=(list @t)] args=*] + [%gen =generator] :: dispatch to an application :: [%app app=term] @@ -225,10 +225,20 @@ == == == +:: +render-tang: renders a tang and adds
tags between each line +:: +++ render-tang + |= {wid/@u tan/tang} + ^- marl + =/ raw=(list tape) (zing (turn tan |=(a/tank (wash 0^wid a)))) + :: + |- ^- marl + ?~ raw ~ + [;/(i.raw) ;br; $(raw t.raw)] :: +internal-server-error: 500 page, with a tang :: ++ internal-server-error - |= [authorized=? url=@t =tang] + |= [authorized=? url=@t t=tang] ^- octs %- as-octs:mimes:html %- crip @@ -242,7 +252,7 @@ ;p:"There was an error while handling the request for {<(trip url)>}." ;* ?: authorized ;= - ;p:"hi" + ;code:"*{(render-tang 80 t)}" == ~ == @@ -319,21 +329,22 @@ ?- -.u.action :: %gen - =/ =disc:ford [our desk.generator.u.action] :: - =- [[duct %pass /run-build/a %f %build our live=%.n schematic=-]~ state] + =- [[duct %pass /run-build %f %build our live=%.n schematic=-]~ state] :: ^- schematic:ford :: - =- [%cast disc %mime -] + =- [%cast [our desk.generator.u.action] %mime -] :: - :: - [%$ %txt !>('one two three')] - :: :+ %call - :: :+ %call - :: [%core [disc path.generator.u.action]] - :: [] - :: [authenticated http-request] + ^- schematic:ford + :+ %call + :+ %call + [%core [[our desk.generator.u.action] (flop path.generator.u.action)]] + :: TODO: Figure out what goes in generators. We need to slop the + :: prelude with the arguments passed in. + :: + [%$ %noun !>([[now=now eny=eny bek=[our desk.generator.u.action [%da now]]] ~ ~])] + [%$ %noun !>([authenticated http-request])] :: %app :_ state @@ -505,11 +516,11 @@ ?: ?=(%incomplete -.made-result) %^ return-static-data-on-duct 500 'text/html' :: TODO: Thread original URL and authentication state here. - (internal-server-error %.n 'http://' tang.made-result) + (internal-server-error %.y 'http://' tang.made-result) :: ?: ?=(%error -.build-result.made-result) %^ return-static-data-on-duct 500 'text/html' - (internal-server-error %.n 'http://' message.build-result.made-result) + (internal-server-error %.y 'http://' message.build-result.made-result) :: =/ =cage (result-to-cage:ford build-result.made-result) :: @@ -796,7 +807,7 @@ %+ add-binding binding.task ?- -.task %connect [%app app.task] - %serve [%gen generator.task arguments.task] + %serve [%gen generator.task] == [moves light-gate] :: @@ -817,7 +828,7 @@ =/ =sign q.wrapped-sign :: :wire must at least contain two parts, the type and the build :: - ?> ?=([@ @ *] wire) + ?> ?=([@ *] wire) :: |^ ^- [p=(list move) q=_light-gate] :: diff --git a/sys/zuse.hoon b/sys/zuse.hoon index 52093dd8a..305ff3433 100644 --- a/sys/zuse.hoon +++ b/sys/zuse.hoon @@ -2240,7 +2240,7 @@ [%connect =binding app=term] :: connects a binding to a generator :: - [%serve =binding generator=[=desk path=(list @t)] arguments=*] + [%serve =binding =generator] :: disconnects a binding :: :: This must be called with the same duct that made the binding in @@ -2270,6 +2270,23 @@ :: path=(list @t) == + :: +generator: a generator on the local ship that handles requests + :: + :: This refers to a generator on the local ship, run with a set of + :: arguments. Since http requests are time sensitive, we require that the + :: generator be on the current ship. + :: + +$ generator + $: :: desk: desk on current ship that contains the generator + :: + =desk + :: path: path on :desk to the generator's hoon file + :: + path=(list @t) + :: args: arguments passed to the gate + :: + args=* + == :: %config: http configuration :: +| %config diff --git a/tests/sys/vane/light.hoon b/tests/sys/vane/light.hoon index 82d04f84a..03414d218 100644 --- a/tests/sys/vane/light.hoon +++ b/tests/sys/vane/light.hoon @@ -628,7 +628,7 @@ :: %+ weld %+ expect-eq - !> /run-build/a + !> /run-build !> p.card :: %+ expect-schematic @@ -643,7 +643,7 @@ now=~1111.1.3 scry=*sley ^= take-args - :* wire=/run-build/a duct=~[/http-blah] + :* wire=/run-build duct=~[/http-blah] ^- (hypo sign:light-gate) :- *type :^ %f %made ~1111.1.3