idea--http-repl 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. id: 'idea--http-repl'
  2. content: |
  3. It might be overkill, but it also might make sense to implement a rich
  4. REPL as a hypermedia API. This would mean that a language could expose
  5. an interactive server on HTTP somewhere.
  6. You could start by requesting the root, which will give you various
  7. options for how to proceed.
  8. GET / HTTP/1.1
  9. HOST: localhost:9999
  10. Accept: application/ld+json
  11. You will then get back a JSON object that describes the current state
  12. of the interpreter and (more importantly) set of links that describe
  13. how to proceed.
  14. HTTP/1.1 200 OK
  15. Content-Type: application/ld+json
  16. Content-Length: ....
  17. Link: </>; rel=index
  18. { "@context": "http://api.example.com/repl"
  19. , "history" : []
  20. , "bindings": []
  21. , "operation":
  22. [ { "@type": "CreateResourceOperation"
  23. , "title": "Evalute an expression"
  24. , "method": "POST"
  25. , "expects": "http://api.example.com/expression"
  26. , "returns": "http://api.example.com/value"
  27. }
  28. ]
  29. }
  30. This gives us a set of options. We can then `POST` a new command to
  31. interpret.
  32. related: []