Module rfc4627_jsonrpc_http

General JSON-RPC HTTP transport support.

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).

Description

General JSON-RPC HTTP transport support.

Used by the Inets HTTP transport library, rfc4627_jsonrpc_inets.

Function Index

invoke_service_method/4Uses AliasPrefix, RequestInfo, Path and Body to locate and invoke a service procedure.

Function Details

invoke_service_method/4

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:

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.

The final result is encoded into a list of bytes using rfc4627:encode/1, and returned along with the ResponseInfo to our caller.


Generated by EDoc, Nov 21 2012, 14:49:54.