1
0
Fork 0
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:
Quinn Slack 2019-11-02 21:39:58 -07:00
parent 456318691a
commit 375ca94e9c
4 changed files with 11 additions and 13 deletions

5
go.mod Normal file
View 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
View 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=

View file

@ -11,7 +11,8 @@ func HandlerWithError(handleFunc func(context.Context, *Conn, *Request) (result
return &HandlerWithErrorConfigurer{handleFunc: handleFunc} return &HandlerWithErrorConfigurer{handleFunc: handleFunc}
} }
// HandlerWithErrorConfigurer is a handler configuration struct
// HandlerWithErrorConfigurer is a handler created by HandlerWithError.
type HandlerWithErrorConfigurer struct { type HandlerWithErrorConfigurer struct {
handleFunc func(context.Context, *Conn, *Request) (result interface{}, err error) handleFunc func(context.Context, *Conn, *Request) (result interface{}, err error)
suppressErrClosed bool suppressErrClosed bool

View file

@ -221,8 +221,6 @@ const (
CodeMethodNotFound = -32601 CodeMethodNotFound = -32601
CodeInvalidParams = -32602 CodeInvalidParams = -32602
CodeInternalError = -32603 CodeInternalError = -32603
// codeServerErrorStart = -32099
// codeServerErrorEnd = -32000
) )
// Handler handles JSON-RPC requests and notifications. // Handler handles JSON-RPC requests and notifications.
@ -642,9 +640,8 @@ func (m *anyMessage) UnmarshalJSON(data []byte) error {
if len(msgs) == 0 { if len(msgs) == 0 {
return errors.New("jsonrpc2: invalid empty batch") return errors.New("jsonrpc2: invalid empty batch")
} }
for i := range msgs { for _, msg := range msgs {
var m = msgs[i] if err := checkType(&msg); err != nil {
if err := checkType(&m); err != nil {
return err return err
} }
} }
@ -695,10 +692,3 @@ func (v *anyValueWithExplicitNull) UnmarshalJSON(data []byte) error {
return json.Unmarshal(data, &v.value) 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")
)
*/