Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

provisions for full json-rpc spec

  • Loading branch information...
commit 57d49bb2f63d0bfbfc07924936ac740248ac886f 1 parent 9d2f565
@mojombo authored
Showing with 13 additions and 5 deletions.
  1. +13 −5 src/yaws_jsonrpc.erl
View
18 src/yaws_jsonrpc.erl
@@ -201,18 +201,26 @@ send(_Args, StatusCode, Payload, AddOnData) ->
A
. % }}}
-encode_handler_payload({response, [ErlStruct]},ID) -> % {{{
- encode_handler_payload({response, ErlStruct}, ID);
+encode_handler_payload({result, [ErlStruct]},ID) -> % {{{
+ encode_handler_payload({result, ErlStruct}, ID);
-encode_handler_payload({response, ErlStruct},ID) ->
- StructStr = json:encode({struct, [ {result, ErlStruct}, {id, ID}]}),
+encode_handler_payload({result, ErlStruct},ID) ->
+ StructStr = json:encode({struct, [ {result, ErlStruct}, {error, null}, {id, case ID of undefined -> ""; Defined -> Defined end}]}),
+ {ok, StructStr};
+
+encode_handler_payload({error, [ErlStruct]},ID) -> % {{{
+ encode_handler_payload({error, ErlStruct}, ID);
+
+encode_handler_payload({error, ErlStruct},ID) ->
+ StructStr = json:encode({struct, [ {result, null}, {error, ErlStruct}, {id, case ID of undefined -> ""; Defined -> Defined end}]}),
{ok, StructStr}. % }}}
+
decode_handler_payload(JSonStr) -> %{{{
try
{ok, JSON} = json:decode_string(JSonStr),
Method = list_to_atom(jsonrpc:s(JSON, method)),
- {array, Args} = jsonrpc:s(JSON, params),
+ {_Kind, Args} = jsonrpc:s(JSON, params),
ID = jsonrpc:s(JSON, id),
{ok, {call, Method, Args}, ID}
Please sign in to comment.
Something went wrong with that request. Please try again.