Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

provisions for full json-rpc spec

  • Loading branch information...
commit 57d49bb2f63d0bfbfc07924936ac740248ac886f 1 parent 9d2f565
Tom Preston-Werner authored

Showing 1 changed file with 13 additions and 5 deletions. Show diff stats Hide diff stats

  1. +13 5 src/yaws_jsonrpc.erl
18 src/yaws_jsonrpc.erl
@@ -201,18 +201,26 @@ send(_Args, StatusCode, Payload, AddOnData) ->
201 201 A
202 202 . % }}}
203 203
204   -encode_handler_payload({response, [ErlStruct]},ID) -> % {{{
205   - encode_handler_payload({response, ErlStruct}, ID);
  204 +encode_handler_payload({result, [ErlStruct]},ID) -> % {{{
  205 + encode_handler_payload({result, ErlStruct}, ID);
206 206
207   -encode_handler_payload({response, ErlStruct},ID) ->
208   - StructStr = json:encode({struct, [ {result, ErlStruct}, {id, ID}]}),
  207 +encode_handler_payload({result, ErlStruct},ID) ->
  208 + StructStr = json:encode({struct, [ {result, ErlStruct}, {error, null}, {id, case ID of undefined -> ""; Defined -> Defined end}]}),
  209 + {ok, StructStr};
  210 +
  211 +encode_handler_payload({error, [ErlStruct]},ID) -> % {{{
  212 + encode_handler_payload({error, ErlStruct}, ID);
  213 +
  214 +encode_handler_payload({error, ErlStruct},ID) ->
  215 + StructStr = json:encode({struct, [ {result, null}, {error, ErlStruct}, {id, case ID of undefined -> ""; Defined -> Defined end}]}),
209 216 {ok, StructStr}. % }}}
  217 +
210 218
211 219 decode_handler_payload(JSonStr) -> %{{{
212 220 try
213 221 {ok, JSON} = json:decode_string(JSonStr),
214 222 Method = list_to_atom(jsonrpc:s(JSON, method)),
215   - {array, Args} = jsonrpc:s(JSON, params),
  223 + {_Kind, Args} = jsonrpc:s(JSON, params),
216 224 ID = jsonrpc:s(JSON, id),
217 225
218 226 {ok, {call, Method, Args}, ID}

0 comments on commit 57d49bb

Please sign in to comment.
Something went wrong with that request. Please try again.