Copyright © 2007-2010, 2011, 2012 Tony Garnock-Jones and 2007-2010 LShift Ltd.
Authors: Erik Timan (dev@timan.info), Tony Garnock-Jones (tonygarnockjones@gmail.com), LShift Ltd. (query@lshift.net).
References
Support for serving JSON-RPC via Cowboy.
Familiarity with writing Cowboy applications is assumed.
AliasPrefix
(see rfc4627_jsonrpc_http:invoke_service_method/4
).handle/2
with your AliasPrefix
and the request.AliasPrefix
, it will be decoded and the JSON-RPC service it names
will be invoked.
handle/2 | If the request matches AliasPrefix , the corresponding
JSON-RPC service is invoked, and an {ok, #http_req{}} is returned;
otherwise, no_match is returned. |
handle(AliasPrefix::string(), Req::#http_req{}) -> no_match | {ok, #http_req{}}
If the request matches AliasPrefix
, the corresponding
JSON-RPC service is invoked, and an {ok, #http_req{}}
is returned;
otherwise, no_match
is returned.
Call this function from your Cowboy HTTP handler's handle
function, as follows:
Req2 = case rfc4627_jsonrpc_cowboy:handle("/rpc", Req) of no_match -> handle_non_jsonrpc_request(Req); {ok, Reponse} -> Response endwhere
handle_non_jsonrpc_request
does the obvious thing for
non-JSON-RPC requests.
Generated by EDoc, Nov 21 2012, 14:49:54.