tricu

An interpreted language for exploring Tree Calculus
Log | Files | Refs | README | LICENSE

registry-base.tri (1484B)


      1 !import prelude *
      2 !import io *
      3 !import http as H
      4 !import consumers_structural as S
      5 !import consumers_lowerings_specialize as P
      6 !import consumers_effect as E
      7 !import consumers_registry_path as Paths
      8 !export *
      9 -- Application adapter: SCP-authored base-library routes and generic effect
     10 -- protocol, with only the domain-specific ReadBundle handler and HTTP
     11 -- conversion here. Both lambda and SCP reference the same path builder.
     12 
     13 readBundle argument = matchPair (root hash :
     14   readFile (Paths.bundleObjectPath root hash)) argument
     15 response wire = matchPair (status more : matchPair
     16   (contentType body : H.response status contentType body) more) wire
     17 
     18 routeExecutable step entry bundle prefix path root request =
     19   onResult_ (E.run step
     20     [(pair "registryEntry" entry) (pair "registryBundle" bundle)]
     21     [(pair "ReadBundle" readBundle)] "registryEntry" request
     22     (pair (S.makeConsumer (pair prefix bundle) (snd path)) root))
     23     (message : pure (H.errorResponse 500 message))
     24     (wire : pure (response wire))
     25 routePrepared entry bundle prefix path root request =
     26   routeExecutable P.runFull entry bundle prefix path root request
     27 routeDirect entry bundle prefix path root request =
     28   routeExecutable P.runDirect entry bundle prefix path root request
     29 routeRun prefix bundle entry path root request =
     30   routePrepared (P.prepareFully entry) (P.prepareFully bundle)
     31     (S.makeConsumer "/_arboricx/bundle/hash/"
     32       (snd (P.prepareFully prefix))) (P.prepareFully path) root request