mirror of
https://github.com/sourcegraph/jsonrpc2.git
synced 2026-06-16 04:04:56 +02:00
add go module, simplify some cleanups
This commit is contained in:
parent
456318691a
commit
375ca94e9c
4 changed files with 11 additions and 13 deletions
5
go.mod
Normal file
5
go.mod
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
module github.com/sourcegraph/jsonrpc2
|
||||
|
||||
go 1.13
|
||||
|
||||
require github.com/gorilla/websocket v1.4.1
|
||||
2
go.sum
Normal file
2
go.sum
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=
|
||||
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
|
|
@ -11,7 +11,8 @@ func HandlerWithError(handleFunc func(context.Context, *Conn, *Request) (result
|
|||
return &HandlerWithErrorConfigurer{handleFunc: handleFunc}
|
||||
}
|
||||
|
||||
// HandlerWithErrorConfigurer is a handler configuration struct
|
||||
|
||||
// HandlerWithErrorConfigurer is a handler created by HandlerWithError.
|
||||
type HandlerWithErrorConfigurer struct {
|
||||
handleFunc func(context.Context, *Conn, *Request) (result interface{}, err error)
|
||||
suppressErrClosed bool
|
||||
|
|
|
|||
14
jsonrpc2.go
14
jsonrpc2.go
|
|
@ -221,8 +221,6 @@ const (
|
|||
CodeMethodNotFound = -32601
|
||||
CodeInvalidParams = -32602
|
||||
CodeInternalError = -32603
|
||||
// codeServerErrorStart = -32099
|
||||
// codeServerErrorEnd = -32000
|
||||
)
|
||||
|
||||
// Handler handles JSON-RPC requests and notifications.
|
||||
|
|
@ -642,9 +640,8 @@ func (m *anyMessage) UnmarshalJSON(data []byte) error {
|
|||
if len(msgs) == 0 {
|
||||
return errors.New("jsonrpc2: invalid empty batch")
|
||||
}
|
||||
for i := range msgs {
|
||||
var m = msgs[i]
|
||||
if err := checkType(&m); err != nil {
|
||||
for _, msg := range msgs {
|
||||
if err := checkType(&msg); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
@ -695,10 +692,3 @@ func (v *anyValueWithExplicitNull) UnmarshalJSON(data []byte) error {
|
|||
return json.Unmarshal(data, &v.value)
|
||||
}
|
||||
|
||||
/*
|
||||
var (
|
||||
errInvalidRequestJSON = errors.New("jsonrpc2: request must be either a JSON object or JSON array")
|
||||
errInvalidResponseJSON = errors.New("jsonrpc2: response must be either a JSON object or JSON array")
|
||||
)
|
||||
*/
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue