Skip to content
DyalogPublic

About

APL-based web service framework supporting JSON or REST

Topics

Resources

Security policy

Stars

41 stars

Watchers

14 watching

Forks

Repository files navigation

Jarvis

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.

Features

  • Two paradigms
    • In the JSON paradigm, each APL function is an endpoint. Jarvis converts JSON to and from APL arrays for you.
    • In the REST paradigm, you write one function per HTTP method (Get, Post and so on) and decide how to handle each resource.
  • 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/jarvis container.

Jarvis runs on Windows, Linux and macOS. It needs Dyalog APL 18.0 or later.

Quick start

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.Start

Call it from APL:

      (HttpCommand.Do 'POST' 'localhost:8080/sum' '[1,3,5]' ('content-type' 'application/json')).Data
9

Or from the command line:

curl -H "content-type: application/json" -d "[1,3,5]" http://localhost:8080/sum

You can also open http://localhost:8080 in a browser to use the HTML interface. To stop the server, run j.Stop.

Documentation

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.

Repository layout

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.

Running the tests

The test suites need dyalogscript, which must be on your PATH or in $DYALOG/scriptbin. To run every suite:

Tests/run-all.sh

License

Jarvis is released under the MIT License.

About

APL-based web service framework supporting JSON or REST

Topics

Resources

Security policy

Stars

41 stars

Watchers

14 watching

Forks

Releases

Contributors

Languages