Module rfc4627_jsonrpc_mochiweb

Support for serving JSON-RPC via Mochiweb.

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

References

Description

Support for serving JSON-RPC via Mochiweb.

Familiarity with writing Mochiweb applications is assumed.

Basic Usage

It's as simple as that - if the request's URI path matches the AliasPrefix, it will be decoded and the JSON-RPC service it names will be invoked.

Function Index

handle/2If the request matches AliasPrefix, the corresponding JSON-RPC service is invoked, and an {ok, Response} is returned; otherwise, no_match is returned.

Function Details

handle/2

handle(AliasPrefix::string(), Req::#mochiweb_request{}) -> no_match | {ok, Response}

If the request matches AliasPrefix, the corresponding JSON-RPC service is invoked, and an {ok, Response} is returned; otherwise, no_match is returned.

Call this function from your Mochiweb application's loop function, as follows:

  case rfc4627_jsonrpc_mochiweb:handle("/rpc", Req) of
       no_match ->
           handle_non_jsonrpc_request(Req);
       {ok, Response} ->
           Req:respond(Response)
  end
where handle_non_jsonrpc_request does the obvious thing for non-JSON-RPC requests.


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