/- sur=nostril /+ sr=sortug /= router /web/router |% ++ handle |= [eyre-id=@ta req=inbound-request:eyre] ^- (unit event:sur) ?~ body.request.req ~ =/ ures (de:json:html q.u.body.request.req) ?~ ures ~ =/ event (event:dejs u.ures) :: TODO log on failure or something `event ++ dejs =, dejs:format |% ++ event |= jon=json ^- event:sur %. jon %- ot :~ id+de-hex pubkey+de-hex ['created_at' ni] kind+ni tags+de-tags content+so sig+de-hex == ++ de-hex |= jon=json ^- @ux ?> ?=(%s -.jon) =/ atom=(unit @) (slaw:sr %ux p.jon) ?~ atom !! u.atom :: ++ de-tags |= jon=json ^- (list tag:sur) ?> ?=(%a -.jon) %+ turn p.jon de-tag ++ de-tag |= j=json ^- tag:sur ?> ?=(%a -.j) =/ l=(list json) p.j =/ key (@t ->.l) =/ value (@t +<+.l) =/ rest ;; (list @t) %+ turn ((list json) +>.l) |= aj=json (@t +.aj) [key value rest] ++ metadata (om so) -- --