source: project/wiki/eggref/5/json-rpc @ 40023

Last change on this file since 40023 was 40023, checked in by rgherdt, 2 months ago
File size: 3.0 KB
Line 
1[[tags: egg]]
2
3== json-rpc
4
5[[toc:]]
6
7=== Description
8
9An implementation of the JSON-RPC for Scheme.
10
11The JSON-RPC allows calling procedures on remote servers by exchanging JSON objects. It's specification can be found at [https://www.jsonrpc.org/specification|https://www.jsonrpc.org/specification].
12
13=== Author
14
15Ricardo G. Herdt
16
17=== Repository
18
19[[https://gitlab.com/rgherdt/scheme-json-rpc.git|https://gitlab.com/rgherdt/scheme-json-rpc.git]]
20
21=== Requirements
22
23* [[r7rs]]
24* [[srfi-1]]
25* [[srfi-18]]
26* [[srfi-69]]
27
28=== Documentation
29
30==== High-level API
31
32<parameter>(json-rpc-handler-table)</parameter>
33
34An association list mapping method names (*strings*) to functions that get an (unmarshalled) scheme object as input. These handlers must return a scheme object that is *mappable* to a JSON string. See [[medea]].
35
36<procedure>(json-rpc-call in-port out-port method params)</procedure>
37<procedure>(json-rpc-call/tcp tcp-address tcp-port method params)</procedure>
38
39Call the remote procedure {{method}} (string) with the JSON-mappable scheme object {{params}}. See [[medea]].
40
41<procedure>(json-rpc-start-server/tcp tcp-port)</procedure>
42
43Listen on {{tcp-port}} and loop over input connections, answering requests according to {{json-rpc-handler-table}}.
44
45==== Low-level API
46<procedure>(json-rpc-read input-port)</procedure>
47
48Read from {{input-port}} and return a Scheme object based on the provided {{json-string->scheme}} parameter.
49
50<procedure>(json-rpc-write scm output-port)</procedure>
51
52Convert the scheme object {{scm}} to a JSON string using the provided paramter {{scheme->json-string}} and writes the result to {{output-port}}.
53
54<procedure>(json-rpc-loop input-port output-port)</procedure>
55
56JSON-RPC 2.0 demands that all requests are answered. This functions loops over {{input-port}} and answers to the requests through {{output-port}} using the handlers defined in {{json-rpc-handler-table}}.
57
58=== Changelog
59
60* 0.0.1 Initial version.
61
62=== LICENSE
63
64MIT License
65
66Copyright (c) 2021 Ricardo G. Herdt
67
68Permission is hereby granted, free of charge, to any person obtaining a
69copy of this software and associated documentation files (the "Software"),
70to deal in the Software without restriction, including without limitation
71the rights to use, copy, modify, merge, publish, distribute, sublicense,
72and/or sell copies of the Software, and to permit persons to whom the
73Software is furnished to do so, subject to the following conditions:
74
75The above copyright notice and this permission notice shall be included in
76all copies or substantial portions of the Software.
77
78THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
79IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
80FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
81THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
82LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
83FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
84DEALINGS IN THE SOFTWARE.
Note: See TracBrowser for help on using the repository browser.