sourcegraph / jsonrpc2

Package jsonrpc2 provides a client and server implementation of JSON-RPC 2.0 (http://www.jsonrpc.org/specification)
MIT License
195 stars 62 forks source link

Always omit params member from request when empty #67

Closed samherrmann closed 1 year ago

samherrmann commented 1 year ago

With this commit, the JSON encoding of Request always omits the params member when calling Conn.Call, Conn.DispatchCall, or Conn.Notify with the params argument set to nil. This change also removes the OmitNilParams call option that was added in commit 8012d496 (#62).

As of this commit, if users desire to send a JSON-RPC request with a params value of null, then they may do so by explicitly setting the params argument of Conn.Call/Conn.DispatchCall/Conn.Notify to json.RawMessage("null").

samherrmann commented 1 year ago

I definitely feel like making this change was a good move considering how simple it is for users to send an explicit null value if they so desire:

conn.Call(ctx, method, json.RawMessage("null"), &result)
samherrmann commented 1 year ago

Once this lands, can we have a 0.2.0 release? That would ensure that the example tests are available when someone visits https://pkg.go.dev/github.com/sourcegraph/jsonrpc2.