40ants-openrpc - A set of helpers to start JSON-RPC server based on https://40ants.com/openrpc/ library.

40ANTS-OPENRPC ASDF System Details

Installation

You can install this library from Quicklisp, but you want to receive updates quickly, then install it from Ultralisp.org:

(ql-dist:install-dist "http://dist.ultralisp.org/"
                      :prompt nil)
(ql:quickload :40ants-openrpc)

Usage

This is a set of opionated helpers for starting Common Lisp OpenRPC servers which uses:

Also, it can manage a multiple OpenRPC servers in the one Lisp image.

The easiest way to start a server is to define one or more api methods using OpenRPC library and then call start. This will bring API on http://localhost:8000/ and it's spec will be available as http://localhost:8000/openrpc.json

This system uses following environment variables to configure the server:

API

40ANTS-OPENRPC/CLIENT

Macros

40ANTS-OPENRPC/JWT

Functions

Encodes payload into a JWT token.

If TTL argument is given, it should be specified in seconds. After this number of seconds, token will become invalid.

Macros
macro
((&REST BINDINGS) &KEY (REQUIRE T) (PROCESSORS '(("roles" . ENSURE-LIST-OF-KEYWORDS)))) &BODY BODY

40ANTS-OPENRPC/SERVER

Functions
function
&key (port \*default-port\*) (api openrpc-server/api::default-api) (interface \*default-interface\*) (debug nil)

Starts Open RPC API server on given PORT and INTERFACE. Also it configures logging and Slynk.

Slynk is started only if SLYNK_PORT env variable is set to some value. You will find more details in the 40ants-slynk system documentation.

function
&key (api openrpc-server/api::default-api)

Entry point for API webserver, started in the Docker or Kubernetes. It works like a start but blocks forever.

function
&key (port \*default-port\*) (interface \*default-interface\*)

Stops API server running on given PORT and INTERFACE.