Skip to content
Brian Becker edited this page Feb 18, 2020 · 4 revisions

Note: This Wiki is currently under construction

Welcome to Jarvis

Jarvis1 is a framework for developing APL-based webservices. Jarvis helps you make your APL code available as a webservices.

A tale of two paradigms

In a nutshell, Jarvis is an HTTP server that receives requests and calls your APL code, passing any parameters from the request to your APL function. It then bundles up the result from your APL function and sends it back as the response to the request. Jarvis implements two types of webservices, JSON-based (JSONServer) and REST-based (RESTServer). JSONServer and RESTServer differ primarily in the way they service requests.

The JSON-based paradigm is the next generation of Dyalog's JSONServer and syntactically compatible with JSONServer found in the JSONServer repository. As such, we'll refer to it as JSONServer in this Wiki. However, the JSONServer available through Jarvis includes features (like session management) not found in the JSONServer repository.

The REST-based paradigm (we'll call it RESTServer) allows you to develop RESTful-style webservices.

JSONServer

The endpoints for your webservice are APL function names. The functions take an APL array as their right argument and return an APL array as their result. Jarvis handles:

  • converting the JSON payload from the HTTP request to an APL array
  • calls your function, passing the APL array
  • takes your APL array result, converts it to JSON and sends it back as the payload in the response

RESTServer

RESTful web services2 use standard HTTP request methods (GET, POST, PUT, DELETE, et al) to specify actions upon the resource specified by the request's URI. The endpoints a RESTServer webservice are APL functions you write to handle the HTTP methods you wish to support. You implement only the methods that make sense for your service. For instance, a read-only service might support only the GET method. It's up to you to decide what URI syntax to implement, how to parse it and how to act upon it.

GET /customer                ⍝ return list of all customers
GET /customer/123            ⍝ return customer 123's information
GET /customer?id=123         ⍝ alternate form to return customer 123's information
GET /customer/123/order      ⍝ return the list of orders for customer 123
GET /customer/123/order/4567 ⍝ return the details of order 4567 for customer 123
GET /customer/123?order=4567 ⍝ alternate form of the above
GET /customer/123/order/4567/status ⍝ return the status of order 4567 for customer 123

1 Why did we call it Jarvis? It turns out that naming something is almost as hard as developing the code for it. Originally we thought of having two repositories (JSONServer and RESTServer), but decided since there was a high overlap in the underlying server code to have a single dual-paradigm repository. A number of names were considered and tossed out (DServer - too ambiguous, HTTPServer - too misleading, etc). Eventually, in frustration, Jarvis was suggested as a tongue-in-cheek option. J.A.R.V.I.S is an intelligent computing system from the Marvel Cinematic Universe, originally seen in the movie "Iron Man". Somehow the name garnered of positive feedback and we "retrofitted" it to mean Json And Rest serVIS.

2This Wiki will not attempt to teach you the principles of RESTful web services; there are many resources expounding many opinions on what a RESTful web service should be. In truth, you have a lot of flexibility to implement your service however makes the most sense to your situation.