Jarvis is Dyalog's web service framework, written in Dyalog APL. It makes your APL functions available over HTTP, so any client that can make an HTTP request can call your APL code. That includes a browser, a phone app, or a program written in Python, C#, JavaScript or APL.
The name is a pseudo-acronym for JSON and REST Service.
- Two paradigms
- In the JSON paradigm, each APL function is an endpoint.
Jarvisconverts JSON to and from APL arrays for you. - In the REST paradigm, you write one function per HTTP method (
Get,Postand so on) and decide how to handle each resource.
- In the JSON paradigm, each APL function is an endpoint.
- A built-in HTML interface lets you try your endpoints from a browser, with no client code.
- Hooks for validation, authentication, session start-up and post-processing.
- Sessions, HTTPS and client certificates, CORS and gzip/deflate compression.
- Server-Sent Events and WebSockets for pushing data to clients.
- Docker support through the public
dyalog/jarviscontainer.
Jarvis runs on Windows, Linux and macOS. It needs Dyalog APL 18.0 or later.
Load HttpCommand, then download and fix the Jarvis class:
]load HttpCommand
HttpCommand.Fix 'https://raw.githubusercontent.com/Dyalog/Jarvis/master/Source/Jarvis.dyalog'This downloads the latest, possibly pre-release, source. For production use, download a released version.
Write an endpoint, then start a server on port 8080 that serves the code in #:
sum←{+/⍵}
j←Jarvis.New ''
(rc msg)←j.StartCall it from APL:
(HttpCommand.Do 'POST' 'localhost:8080/sum' '[1,3,5]' ('content-type' 'application/json')).Data
9Or from the command line:
curl -H "content-type: application/json" -d "[1,3,5]" http://localhost:8080/sumYou can also open http://localhost:8080 in a browser to use the HTML interface. To stop the server, run j.Stop.
The full documentation is at https://dyalog.github.io/Jarvis. It covers concepts, settings, the Request object and release notes.
The source for the documentation is in docs. To preview it locally, run mkdocs serve.
| Folder | Contents |
|---|---|
Source |
The Jarvis class, Jarvis.dyalog. This single file is all you need to use Jarvis. |
Samples |
Example services: JSON endpoints, a REST service, and live HTML, SSE and WebSocket demos. |
Demos, Jarvis.demo |
Scripts that walk through Jarvis, using either two interpreters (a server and a client) or one. |
Docker |
Files for building the dyalog/jarvis container image. |
Service |
Support for running Jarvis as a Windows service. |
Distribution |
Prebuilt Jarvis.dws and JarvisService.dws workspaces. |
Tests |
dyalogscript test suites. |
docs |
Documentation source, built with MkDocs. |
Plans |
Design documents for features in development. |
The test suites need dyalogscript, which must be on your PATH or in $DYALOG/scriptbin. To run every suite:
Tests/run-all.shJarvis is released under the MIT License.