from tinyrpc.protocols.jsonrpc import JSONRPCProtocol
from tinyrpc import BadRequestError
from tinyrpc.dispatch import RPCDispatcher
dispatch = RPCDispatcher()
dispatch.add_method(lambda a,b: a+b, "add")
dispatch.add_method(lambda s: s, "echo")
rpc = JSONRPCProtocol()
request = rpc.create_request("add", args=[1,2])
print(request.serialize())
response = dispatch.dispatch(request)
print(response.serialize())
dispatch.validator=None
response2 = dispatch.dispatch(request)
print(response2.serialize())
## -- End pasted text --
b'{"jsonrpc": "2.0", "method": "add", "params": [1, 2], "id": 1}'
b'{"jsonrpc": "2.0", "id": 1, "error": {"message": "Invalid params", "code": -32602}}'
b'{"jsonrpc": "2.0", "id": 1, "error": {"message": "<lambda>() argument after ** must be a mapping, not NoneType", "code": -32000}}'
I expected both the 2nd and the 3rd prints to show a succesful method call. It seems like the default request value for kwargs must be None which invalid for use with **. Would {} be a better default?
I expected both the 2nd and the 3rd prints to show a succesful method call. It seems like the default request value for
kwargs
must beNone
which invalid for use with**
. Would{}
be a better default?