40ants-openrpc - A set of helpers to start JSON-RPC server based on https://40ants.com/openrpc/ library.
40ANTS-OPENRPC ASDF System Details
Description: A set of helpers to start
JSON-RPC
server based on https://40ants.com/openrpc/ library.Licence: Unlicense
Author: Alexander Artemenko <svetlyak.40wt@gmail.com>
Homepage: https://40ants.com/40ants-openrpc/
Bug tracker: https://github.com/40ants/40ants-openrpc/issues
Source control: GIT
Depends on: 40ants-logging, 40ants-slynk, alexandria, cl+ssl, cl-json-web-tokens, clack, clack-cors, clack-prometheus, dexador, jsonrpc, lack-request, local-time, log4cl, log4cl-extras, openrpc-client, openrpc-server, serapeum, with-user-abort
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:
https://40ants.com/openrpc/
https://40ants.com/logging/
https://40ants.com/slynk/
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:
APP_PORT
andAPP_INTERFACE
are used instart-in-production
function to control on which port and interfaceAPI
should be started on.DEBUG
also used instart-in-production
function to control how verbose logging should be. If it is given then logging will be withDEBUG
level.CORS_ALLOWED_ORIGIN
andCORS_ALLOWED_HEADERS
are control howAPI
will respond withCORS
related headers. Learn more about used middleware inclack-cors
system documentation.
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
40ANTS-OPENRPC/SERVER
Functions
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.
Entry point for API
webserver, started in the Docker or Kubernetes.
It works like a start
but blocks forever.
Stops API
server running on given PORT
and INTERFACE
.