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

Accept a `nil` handler #53

Closed josebalius closed 2 years ago

josebalius commented 2 years ago

At day job we use this package for mostly client interactions with an RPC server. At the moment we are forced to implement a noopHandler since we don't care about any requests made to us. It could be a nicer API if a nil handler could be provided and the pkg to ignore requests in that case.

Is this something you'll accept a PR for? It's only a few lines to update to guard against nil handlers.

keegancsmith commented 2 years ago

Guarding against nil handlers sounds good to me.

josebalius commented 2 years ago

Opened a PR: https://github.com/sourcegraph/jsonrpc2/pull/55

Edit: Went with a different approach than what I suggest here but I believe it is better.