Skip to content

40ants/40ants-openrpc

Repository files navigation

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:

  • APP_PORT and APP_INTERFACE are used in start-in-production function to control on which port and interface API should be started on.
  • DEBUG also used in start-in-production function to control how verbose logging should be. If it is given then logging will be with DEBUG level.
  • CORS_ALLOWED_ORIGIN and CORS_ALLOWED_HEADERS are control how API will respond with CORS related headers. Learn more about used middleware in clack-cors system documentation.

API

40ANTS-OPENRPC/CLIENT

package 40ants-openrpc/client

Macros

macro 40ants-openrpc/client:generate-client name url

40ANTS-OPENRPC/JWT

package 40ants-openrpc/jwt

Functions

function 40ants-openrpc/jwt:decode token

function 40ants-openrpc/jwt:issue-token payload &key ttl

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 40ants-openrpc/jwt:with-session ((&REST BINDINGS) &KEY (REQUIRE T) (PROCESSORS '(("roles" . ENSURE-LIST-OF-KEYWORDS)))) &BODY BODY

macro 40ants-openrpc/jwt:with-test-token (token) &body body

40ANTS-OPENRPC/SERVER

package 40ants-openrpc/server

Functions

function 40ants-openrpc/server:start &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 40ants-openrpc/server:start-in-production &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 40ants-openrpc/server:stop &key (port *default-port*) (interface *default-interface*)

Stops API server running on given PORT and INTERFACE.


[generated by 40ANTS-DOC]

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published