diff --git a/cmd/grpcurl/grpcurl.go b/cmd/grpcurl/grpcurl.go index be24759..57b714d 100644 --- a/cmd/grpcurl/grpcurl.go +++ b/cmd/grpcurl/grpcurl.go @@ -427,7 +427,7 @@ func (*handler) OnSendHeaders(md metadata.MD) { } } -func (h *handler) getRequestData() (json.RawMessage, error) { +func (h *handler) getRequestData() ([]byte, error) { // we don't use a mutex, though this methods will be called from different goroutine // than other methods for bidi calls, because this method does not share any state // with the other methods. diff --git a/grpcurl.go b/grpcurl.go index 5ca72da..095ac88 100644 --- a/grpcurl.go +++ b/grpcurl.go @@ -11,7 +11,6 @@ import ( "crypto/tls" "crypto/x509" "encoding/base64" - "encoding/json" "errors" "fmt" "io" @@ -275,7 +274,7 @@ type InvocationEventHandler interface { // RequestMessageSupplier is a function that is called to retrieve request // messages for a GRPC operation. The message contents must be valid JSON. If // the supplier has no more messages, it should return nil, io.EOF. -type RequestMessageSupplier func() (json.RawMessage, error) +type RequestMessageSupplier func() ([]byte, error) // InvokeRpc uses te given GRPC connection to invoke the given method. The given descriptor source // is used to determine the type of method and the type of request and response message. The given @@ -406,7 +405,7 @@ func invokeClientStream(ctx context.Context, stub grpcdynamic.Stub, md *desc.Met // Upload each request message in the stream var resp proto.Message for err == nil { - var data json.RawMessage + var data []byte data, err = requestData() if err == io.EOF { resp, err = str.CloseAndReceive() @@ -528,7 +527,7 @@ func invokeBidi(ctx context.Context, cancel context.CancelFunc, stub grpcdynamic // Concurrently upload each request message in the stream var err error - var data json.RawMessage + var data []byte for err == nil { data, err = requestData() diff --git a/grpcurl_test.go b/grpcurl_test.go index 5322fac..453fcb2 100644 --- a/grpcurl_test.go +++ b/grpcurl_test.go @@ -1,7 +1,6 @@ package grpcurl_test import ( - "encoding/json" "fmt" "io" "net" @@ -568,7 +567,7 @@ type handler struct { respTrailersCount int } -func (h *handler) getRequestData() (json.RawMessage, error) { +func (h *handler) getRequestData() ([]byte, error) { // we don't use a mutex, though this method will be called from different goroutine // than other methods for bidi calls, because this method does not share any state // with the other methods. @@ -580,7 +579,7 @@ func (h *handler) getRequestData() (json.RawMessage, error) { // insert delay between messages in request stream time.Sleep(time.Millisecond * 50) } - return json.RawMessage(h.reqMessages[h.reqMessagesCount-1]), nil + return []byte(h.reqMessages[h.reqMessagesCount-1]), nil } func (h *handler) OnResolveMethod(md *desc.MethodDescriptor) {