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).
General JSON-RPC HTTP transport support.
Used by the Inets HTTP transport library,rfc4627_jsonrpc_inets
.
invoke_service_method/4 | Uses AliasPrefix , RequestInfo , Path and Body to locate
and invoke a service procedure. |
invoke_service_method(AliasPrefix, Path, RequestInfo, Body) -> Result
Uses AliasPrefix
, RequestInfo
, Path
and Body
to locate
and invoke a service procedure.
If AliasPrefix
is default
, the default prefix "/jsonrpc"
is used.
Path
is expected to be the "path" part of the request URI: a string of the form "/.../prefix/objectname[/methodname]".
RequestInfo
is a JSON "object" containing HTTP-specific request information:
http_method
should be either <<"GET">>
(the default) or <<"POST">>
http_query_parameters
should be the query parameters (the part of the URL after "?")
decoded into a JSON "object", with one field per parameterhttp_headers
should be a JSON "object" containing the HTTP request headersscheme
should be either <<"http">>
or <<"https">>
remote_port
should be the TCP port number of the remote peerremote_peername
should be a binary()
containing the IP address of the
remote peer, in a form acceptable to inet:gethostbyaddr/1
All the fields in RequestInfo
are optional.
Body
must be either a binary()
or a string()
containing the HTTP request body.
Operation proceeds as follows. Path
is first matched against
AliasPrefix
. If it does not match, no_match
is
returned. Otherwise, the matching prefix is stripped from the path,
and extraction of the service name, method name, and parameters from
the HTTP request proceeds as per the JSON-RPC specification,
[JSON-RPC-1-1-WD-20060807.html#ProcedureCall].
Once the service name, method name and parameters are known, The
service is looked up with rfc4627_jsonrpc:lookup_service/1
,
and the named method is invoked with rfc4627_jsonrpc:invoke_service_method/8
.
rfc4627:encode/1
, and returned along with the ResponseInfo
to
our caller.
Generated by EDoc, Nov 21 2012, 14:49:54.