tricu

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

arboricxServer.tri (788B)


      1 !import "prelude"         !Local
      2 !import "io"              !Local
      3 !import "arboricx.server" !Local
      4 
      5 -- Arboricx HTTP registry server demo.
      6 -- Run with --allow-write ./store --allow-read ./store
      7 --
      8 -- Endpoints:
      9 --   GET  /_arboricx/health          -> "OK"
     10 --   POST /_arboricx/bundle          -> upload bundle, returns hash
     11 --   GET  /_arboricx/bundle/hash/:h  -> download bundle by hash
     12 --
     13 -- Example usage:
     14 --   curl http://localhost:9050/_arboricx/health
     15 --   curl -X POST --data-binary @mybundle.arboricx http://localhost:9050/_arboricx/bundles
     16 --   curl http://localhost:9050/_arboricx/bundle/hash/<hash>
     17 
     18 main = io (thenIO
     19   (putStrLn "Starting Arboricx server on 127.0.0.1:9050")
     20   (thenIO
     21     (void (ensureStore "/tmp/store"))
     22     (arboricxServer "/tmp/store" "127.0.0.1" 9050)))