Module rfc4627_jsonrpc_cowboy

Support for serving JSON-RPC via Cowboy.

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

Description

Support for serving JSON-RPC via Cowboy.

Familiarity with writing Cowboy 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, #http_req{}} is returned; otherwise, no_match is returned.

Function Details

handle/2

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
        end
where handle_non_jsonrpc_request does the obvious thing for non-JSON-RPC requests.


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