mirror of
https://github.com/sourcegraph/jsonrpc2.git
synced 2026-06-16 04:04:56 +02:00
Guard against nil handlers
This commit is contained in:
parent
c9c77b6bb9
commit
4a67c7872c
1 changed files with 6 additions and 1 deletions
|
|
@ -355,6 +355,7 @@ func (id *ID) UnmarshalJSON(data []byte) error {
|
|||
type Conn struct {
|
||||
stream ObjectStream
|
||||
|
||||
// If Handler is nil, incoming requests are skipped
|
||||
h Handler
|
||||
|
||||
mu sync.Mutex
|
||||
|
|
@ -620,7 +621,11 @@ func (c *Conn) readMessages(ctx context.Context) {
|
|||
for _, onRecv := range c.onRecv {
|
||||
onRecv(m.request, nil)
|
||||
}
|
||||
c.h.Handle(ctx, c, m.request)
|
||||
|
||||
// If handler is not nil, handle the request.
|
||||
if c.h != nil {
|
||||
c.h.Handle(ctx, c, m.request)
|
||||
}
|
||||
|
||||
case m.response != nil:
|
||||
resp := m.response
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue