Module: JsonRpc

Defined in:
lib/json-rpc.rb

Defined Under Namespace

Modules: Rpc

Instance Method Summary collapse

Instance Method Details

#rpc_call(env, &ecb) ⇒ Object

Call the correct method for each query The method should be prefixed by rpc_ If the method doesn’t exists, an error will be return in JSON More details in groups.google.com/group/json-rpc/web/json-rpc-2-0



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/json-rpc.rb', line 11

def rpc_call env, &ecb
  begin
    request = Rpc::parse env
    status = Rpc::validate request
    result = Rpc::route request, self

  rescue Rpc::Error => e
    status = e.status
    result = e.result
    ecb.call(e) if ecb
  end

  [status, {'Content-Type' => Rpc::ContentType}, result]
end