diff --git a/handler_with_error.go b/handler_with_error.go index 11cd945..81c5546 100644 --- a/handler_with_error.go +++ b/handler_with_error.go @@ -3,7 +3,6 @@ package jsonrpc2 import ( "context" "log" - "reflect" ) // HandlerWithError implements Handler by calling the func for each @@ -22,9 +21,6 @@ func (h HandlerWithError) Handle(ctx context.Context, conn *Conn, req *Request) resp := &Response{ID: req.ID} if err == nil { - if isNilValue(result) { - result = struct{}{} - } err = resp.SetResult(result) } if err != nil { @@ -41,17 +37,3 @@ func (h HandlerWithError) Handle(ctx context.Context, conn *Conn, req *Request) } } } - -// isNilValue tests if an interface is empty, because an empty interface does -// not encode any information, we can't encode it in JSON so that the proxy -// knows it's a response, not a request. -func isNilValue(resp interface{}) bool { - if resp == nil { - return true - } - kind := reflect.TypeOf(resp).Kind() - value := reflect.ValueOf(resp) - nilPtr := kind == reflect.Ptr && value.IsNil() - nilSlice := kind == reflect.Slice && value.IsNil() - return nilPtr || nilSlice -}