Skip to content

tonyg/erlang-rfc4627

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RFC4627 (JSON) and JSON-RPC for Erlang

An implementation of JSON and JSON-RPC for Erlang.

See rfc4627.erl, the JSON/RFC4627 codec itself, to learn how to encode and decode JSON objects from Erlang code.

Providing and calling JSON-RPC services

See rfc4627_jsonrpc.erl, a JSON-RPC service registry and transport-neutral service method invocation mechanism, to learn how to expose Erlang processes as remotely-callable JSON-RPC services, and to learn how to invoke local JSON-RPC services from Erlang without the overhead of HTTP.

Exposing JSON-RPC services over HTTP

Using Inets

See rfc4627_jsonrpc_inets.erl, an Inets HTTP transport binding for JSON-RPC, to learn how to configure the Inets HTTP server to respond to JSON-RPC requests.

Using Mochiweb

See rfc4627_jsonrpc_mochiweb.erl to learn how to delegate incoming Mochiweb HTTP requests to the JSON-RPC service dispatcher.

Using Cowboy

See rfc4627_jsonrpc_cowboy.erl to learn how to delegate incoming Cowboy HTTP requests to the JSON-RPC service dispatcher.

Running the example test service that comes with the source code

Included with the Erlang RFC4627 source code is a small Inets-based example that defines a "hello world"-style JSON-RPC service, and calls it from a Javascript program embedded in a web page.

At your Erlang shell,

  • after compiling the code with make all test-compile,
  • when your current working directory contains the test directory from the distribution, such that ./test/server_root/conf/httpd.conf exists,

type test_jsonrpc_inets:start_httpd(). (Don't forget the trailing "."!) This will

  • start the inets httpd on port 5671 (from ./test/server_root/conf/httpd.conf)
  • allow HTTP access to JSON-RPC services via a url prefix of /rpc (again from httpd.conf)
  • start the rfc4627_jsonrpc service registry
  • register the test service

Visiting http://localhost:5671/ in your browser should load a page that uses javascript to invoke the Erlang-implemented JSON-RPC test service.

Invoking JSON-RPC procedures from Javascript

See the relevant section of the edoc documentation included with the source code.

References

Contributors

The codebase and documentation was originally written between 2007 and 2010 by Tony Garnock-Jones while at LShift in London. Since then, it has been maintained by Tony and enhanced with a few generous contributions from others:

  • András Veres-Szentkirályi
  • Eugene Volchek
  • Simon MacMullen
  • Andrey Khozov
  • Erik Timan

Copyright and Licence

Copyrights:

  • Copyright © 2007-2010, 2011, 2012 Tony Garnock-Jones.
  • Portions copyright 2007-2010 LShift Ltd.
  • Portions copyright contributors to the project, listed above.

License (MIT):

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

About

Erlang RFC4627 (JSON) codec and JSON-RPC server implementation.

Resources

Stars

Watchers

Forks

Packages

No packages published