/+ *sortug |% +$ card card:agent:gall +$ eyre-poke [id=@da req=inbound-request:eyre] :: our paths are particular +$ paeth (list @t) +$ req-path [=method:http paeth] +$ route-map (map req-path simple-payload:http) +$ data [=order state=mold] :: I'd rather it can be a non-simple payload but whatever +$ route $-(inbound-request route-end) ++ de-path :: modified from apat:de-purl:html =/ delim ;~(pose fas dot) %+ cook :: get rid of the last dot and make the extension a part of the path |= l=paeth ^+ l =/ acc [nl=*_l i=1] %^ spin l acc |= [e=@t a=acc] :- e :_ +(i) :: only change the last one ?. .=(i (lent l)) a.a (rash last (csplit dot)) ;~(pfix fas (more fas smeg:de-purl:html)) ++ parse-url-path |= url=@t ^- request-line (fall (rush url ;~(plug de-path yque:de-purl:html)) [[~ ~] ~]) ++ $ =state |* state-type=mold =/ met method.request.req.order =/ req-line (parse-request-line url.request.req.order) =/ pth=path :- met site.req-line ?+ pth :_ state (serve-404 req-line) [%'GET' ~ ~] :_ state (serve-index req-line) :: "/" [%'GET' @ @ @ @ *] :_ state (serve-post site.req-line) [%'POST' *] (handle-post req-line body.request.req.order state) :: [%get %blog *] serve-blog :: [%get 'chat' *] serve-chat :: [%get 'forum' *] serve-forum :: [%get 'about' *] serve-about == :: The api we want is (route eyre-poke route-map state bowl) :: route-map is + :: and from that we get [(list card) simple-payload:http _state] which the router itself resolves to (quip card _state) --