1
0
Fork 0
mirror of https://github.com/sourcegraph/jsonrpc2.git synced 2026-06-19 05:30:03 +02:00
Commit graph

2 commits

Author SHA1 Message Date
Sam Herrmann
c5d79b7c37 Add ability to omit params member from request
The JSON-RPC 2.0 specification allows the params member of a request to
be omitted [1]. Before this commit, this library did not allow the
params member to be omitted. When the params argument of the Conn.Call
or Conn.Notify method was set to nil, then Request.Params was set to the
JSON encoding of nil which is null.

This commit adds a ConnOption named OmitNilParams. If OmitNilParams is
applied on Conn and Conn.Call or Conn.Notify are invoked with their
params argument set to nil, then the params member in the JSON encoding
of Request is omitted. If the OmitNilParams option is not applied on
Conn then the previous behavior is maintained. In other words, the
changes in this commit are backwards compatible.

References
[1]: https://www.jsonrpc.org/specification#request_object
2023-01-18 21:03:51 -05:00
Sam Herrmann
c9c77b6bb9
Add ability to set custom logger (#48)
Before this commit, a custom logger could be set with the LogMessages
function. However, by using LogMessages not only is a custom logger set
but also all received and sent messages are logged. Use cases exist
where a custom logger is desired to log errors but not all messages.
2021-11-19 10:30:03 +02:00