Copyright © 2007-2010, 2011, 2012 Tony Garnock-Jones and 2007-2010 LShift Ltd.
Introduced in: 1.2.0
Authors: Tony Garnock-Jones (tonygarnockjones@gmail.com), LShift Ltd. (query@lshift.net).
An extension module for the Inets HTTP server, providing HTTP access to JSON-RPC services.
The inets httpd uses an httpd.conf
file to configure itself. To
enable HTTP access to registered JSON-RPC services, two things need
to be added to the httpd configuration file:
rfc4627_jsonrpc_inets
in the Modules
configuration directive (just after mod_alias
and mod_auth
will do)JsonRpcAlias
directive, specifying a subspace of the URLs served by the httpd that will be mapped to JSON-RPC service requests (the value used as AliasPrefix
in calls to rfc4627_jsonrpc_http:invoke_service_method/4
)Here's a complete httpd.conf
:
ServerName localhost ServerRoot test/server_root DocumentRoot test/server_root/htdocs Port 5671 Modules mod_alias mod_auth rfc4627_jsonrpc_inets mod_actions mod_cgi mod_responsecontrol mod_trace mod_range mod_head mod_include mod_dir mod_get mod_log mod_disk_log DirectoryIndex index.html JsonRpcAlias /rpc ErrorLog logs/error_log TransferLog logs/access_log SecurityLog logs/security_log</pre>
If an httpd server is started from this configuration, it will
/rpc
The URL structure for JSON-RPC requests will be
http://localhost:5671/rpc/ServiceName
where ServiceName is the rfc4627_jsonrpc:register_service/2
'd name of the service. For
instance, the example "hello world" service defined in
test_jsonrpc_inets.erl
would be accessible at
http://localhost:5671/rpc/test
The built-in service description method, system.describe
, is
accessible via a POST to that URL, or a GET to
http://localhost:5671/rpc/test/system.describe
Similarly, any idempotent methods provided by a service may be accessed via POST to the base URL for the service, or via GET to a URL of the form
http://localhost:5671/rpc/ServiceName/MethodName?arg=value&...
do/1 | Implements the inets httpd main callback interface. |
load/2 | Parses the "JsonRpcAlias" configuration entry from the inets httpd.conf file. |
do(ModData::#mod{}) -> {proceed, term()}
Implements the inets httpd main callback interface.
Calls out torfc4627_jsonrpc_http:invoke_service_method/4
.
load(Line::string(), AccIn::term()) -> {ok, AccOut::term(), {atom(), term()}}
Parses the "JsonRpcAlias"
configuration entry from the inets httpd.conf
file.
Generated by EDoc, Nov 21 2012, 14:49:54.