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

9 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
s3rj1k
81af42d766 minor logging fixes
Signed-off-by: s3rj1k <evasive.gyron@gmail.com>
2019-11-07 23:44:16 +02:00
s3rj1k
6053545ad1 use custom logger for internal logging
Signed-off-by: s3rj1k <evasive.gyron@gmail.com>
2019-11-03 22:30:34 +02:00
Sergey Mudrik
549eb959f0 Replaced log.Logger parameter by interface (#20) 2018-08-31 09:05:25 -07:00
Keegan Carruthers-Smith
a3d86c792f allow multiple OnRecv and OnSend 2018-05-01 19:02:17 +01:00
Keegan Carruthers-Smith
7e53931322 Use correct format string for ID
Audited all calls for Printf. Noticed the following in some logs

```
jsonrpc2 handler: sending response {1 %!d(string=) %!d(bool=false)}: jsonrpc2: connection is closed
```
2016-11-14 21:17:22 +02:00
Quinn Slack
6416f80f8f support string request IDs (in addition to numeric request IDs) 2016-11-06 07:12:05 -08:00
Quinn Slack
c04eec1600 initial commit 2016-10-11 15:56:18 +02:00