gorilla / rpc

Package gorilla/rpc is a golang foundation for RPC over HTTP services.
https://gorilla.github.io
BSD 3-Clause "New" or "Revised" License
590 stars 179 forks source link

Fix encoding request when params are nil #77

Closed MarinX closed 1 year ago

MarinX commented 4 years ago

Fixes #54

Summary of Changes

When calling method with args nil, the interface marshals into null, which gives us params: [null] and RPC server that does not require parameter will yield error. This fix sets the params only if args are not nil, otherwise it will be an empty interface which will give us params: []

coreydaley commented 1 year ago

Is there a test that can updated/added to verify this and ensure that we don't have any regressions in the future? (also need to fix the conflict)

MarinX commented 1 year ago

Going to close this PR request because it's wrong.

The difference between jsonrpc 1 and jsonrpc 2 is that params may be omitted

The package rpc/v2/json2 contains a client which omits that field (readme also points rpc/v2 support for JSON-RPC 2.0 Specification) .

I was just using the wrong client (1.0) instead of the correct one(2.0)