浏览代码

added http-repl idea

Getty Ritter 9 年之前
父节点
当前提交
4c26b06a1d
共有 1 个文件被更改,包括 38 次插入0 次删除
  1. 38 0
      scraps/idea--http-repl

+ 38 - 0
scraps/idea--http-repl

@@ -0,0 +1,38 @@
+id: 'idea--http-repl'
+content: |
+  It might be overkill, but it also might make sense to implement a rich
+  REPL as a hypermedia API. This would mean that a language could expose
+  an interactive server on HTTP somewhere.
+
+  You could start by requesting the root, which will give you various
+  options for how to proceed.
+
+      GET / HTTP/1.1
+      HOST: localhost:9999
+      Accept: application/ld+json
+
+  You will then get back a JSON object that describes the current state
+  of the interpreter and (more importantly) set of links that describe
+  how to proceed.
+
+      HTTP/1.1 200 OK
+      Content-Type: application/ld+json
+      Content-Length: ....
+      Link: </>; rel=index
+
+      { "@context": "http://api.example.com/repl"
+      , "history" : []
+      , "bindings": []
+      , "operation":
+        [ { "@type": "CreateResourceOperation"
+          , "title": "Evalute an expression"
+          , "method": "POST"
+          , "expects": "http://api.example.com/expression"
+          , "returns": "http://api.example.com/value"
+          }
+        ]
+      }
+
+  This gives us a set of options. We can then `POST` a new command to
+  interpret.
+related: []