Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 129 lines (94 sloc) 4.774 kB
7a3ad6a @tonyg README, and fix link rot
authored
1 # RFC4627 (JSON) and JSON-RPC for Erlang
2
3 An implementation of JSON and JSON-RPC for Erlang.
4
5 See
6 [rfc4627.erl](http://tonyg.github.com/erlang-rfc4627/doc/rfc4627.html),
7 the JSON/RFC4627 codec itself, to learn how to encode and decode JSON
8 objects from Erlang code.
9
10 ## Providing and calling JSON-RPC services
11
12 See
13 [rfc4627\_jsonrpc.erl](http://tonyg.github.com/erlang-rfc4627/doc/rfc4627_jsonrpc.html),
14 a JSON-RPC service registry and transport-neutral service method
15 invocation mechanism, to learn how to expose Erlang processes as
16 remotely-callable JSON-RPC services, and to learn how to invoke local
17 JSON-RPC services from Erlang without the overhead of HTTP.
18
19 ## Exposing JSON-RPC services over HTTP
20
21 ### Using Inets
22
23 See
24 [rfc4627\_jsonrpc\_inets.erl](http://tonyg.github.com/erlang-rfc4627/doc/rfc4627_jsonrpc_inets.html),
25 an Inets HTTP transport binding for JSON-RPC, to learn how to
26 configure the Inets HTTP server to respond to JSON-RPC requests.
27
28 ### Using Mochiweb
29
30 See
31 [rfc4627\_jsonrpc\_mochiweb.erl](http://tonyg.github.com/erlang-rfc4627/doc/rfc4627_jsonrpc_mochiweb.html)
32 to learn how to delegate incoming Mochiweb HTTP requests to the
33 JSON-RPC service dispatcher.
34
89dc8b9 @olcai Add support for Cowboy.
olcai authored
35 ### Using Cowboy
36
37 See
38 [rfc4627\_jsonrpc\_cowboy.erl](http://tonyg.github.com/erlang-rfc4627/doc/rfc4627_jsonrpc_cowboy.html)
39 to learn how to delegate incoming Cowboy HTTP requests to the
40 JSON-RPC service dispatcher.
41
7a3ad6a @tonyg README, and fix link rot
authored
42 ## Running the example test service that comes with the source code
43
44 Included with the Erlang RFC4627 source code is a small Inets-based
45 example that defines a "hello world"-style JSON-RPC service, and calls
46 it from a Javascript program embedded in a web page.
47
48 At your Erlang shell,
49
50 - after compiling the code with `make all test-compile`,
51 - when your current working directory contains the `test` directory
52 from the distribution, such that
53 `./test/server_root/conf/httpd.conf` exists,
54
55 type `test_jsonrpc_inets:start_httpd().` (Don't forget the trailing
56 "."!) This will
57
58 - start the inets httpd on port 5671 (from `./test/server_root/conf/httpd.conf`)
59 - allow HTTP access to JSON-RPC services via a url prefix of `/rpc` (again from `httpd.conf`)
60 - start the `rfc4627_jsonrpc` service registry
61 - register the test service
62
63 Visiting <http://localhost:5671/> in your browser should load a page
64 that uses javascript to invoke the Erlang-implemented JSON-RPC test
65 service.
66
67 ## Invoking JSON-RPC procedures from Javascript
68
69 See the [relevant
70 section](http://tonyg.github.com/erlang-rfc4627/doc/overview-summary.html#Invoking_JSON-RPC_procedures_from_Javascript)
71 of the `edoc` documentation included with the source code.
72
73 ## References
74
75 - the [JSON RFC](http://www.ietf.org/rfc/rfc4627.txt).
76
77 - the [JSON-RPC
78 specification](http://json-rpc.org/wd/JSON-RPC-1-1-WD-20060807.html)
79 1.1 working draft ([mirrored
80 locally](http://tonyg.github.com/erlang-rfc4627/doc/JSON-RPC-1-1-WD-20060807.html)).
81
82 - Joe Armstrong's
83 [message](http://erlang.org/pipermail/erlang-questions/2005-November/017805.html)
84 describing the basis of the JSON data type mapping that the
85 `rfc4627.erl` module uses.
86
87 ## Contributors
88
89 The codebase and documentation was originally written between 2007 and
90 2010 by Tony Garnock-Jones while at LShift in London. Since then, it
91 has been maintained by Tony and enhanced with a few generous
92 contributions from others:
93
94 - András Veres-Szentkirályi
95 - Eugene Volchek
96 - Simon MacMullen
97 - Andrey Khozov
89dc8b9 @olcai Add support for Cowboy.
olcai authored
98 - Erik Timan
7a3ad6a @tonyg README, and fix link rot
authored
99
100 ## Copyright and Licence
101
102 Copyrights:
103
104 - Copyright &copy; 2007-2010, 2011, 2012 Tony Garnock-Jones.
105 - Portions copyright 2007-2010 LShift Ltd.
106 - Portions copyright contributors to the project, listed above.
107
108 License (MIT):
109
110 Permission is hereby granted, free of charge, to any person
111 obtaining a copy of this software and associated documentation
112 files (the "Software"), to deal in the Software without
113 restriction, including without limitation the rights to use, copy,
114 modify, merge, publish, distribute, sublicense, and/or sell copies
115 of the Software, and to permit persons to whom the Software is
116 furnished to do so, subject to the following conditions:
117
118 The above copyright notice and this permission notice shall be
119 included in all copies or substantial portions of the Software.
120
121 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
122 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
123 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
124 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
125 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
126 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
127 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
128 SOFTWARE.
Something went wrong with that request. Please try again.