From 2ff725abb27e25b5dc164f5ddf7935769cf42e0d Mon Sep 17 00:00:00 2001 From: Joshua Humphries Date: Fri, 6 Jul 2018 09:13:34 +0200 Subject: [PATCH] add -d examples to README resolves #37 --- README.md | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d55977c..81c1083 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,16 @@ run `make install`. If you encounter compile errors, you could have out-dated versions of `grpcurl`'s dependencies. You can update the dependencies by running `make updatedeps`. -## Example Usage +## Usage +The usage doc for the tool explains the numerous options: +```shell +grpcurl -help +``` + +In the sections below, you will find numerous examples demonstrating how to use +`grpcurl`. + +### Invoking RPCs Invoking an RPC on a trusted server (e.g. TLS without self-signed key or custom CA) that requires no client certs and supports service reflection is the simplest thing to do with `grpcurl`. This minimal invocation sends an empty request body: @@ -66,6 +75,32 @@ do with `grpcurl`. This minimal invocation sends an empty request body: grpcurl grpc.server.com:443 my.custom.server.Service/Method ``` +To send a non-empty request, use the `-d` argument. Note that all arguments must come +*before* the server address and method name: +```shell +grpcurl -d '{"id": 1234, "tags": ["foo","bar"]}' \ + grpc.server.com:443 my.custom.server.Service/Method +``` + +As can be seen in the example, the supplied body must be in JSON format. The body will +be parsed and then transmitted to the server in the protobuf binary format. + +If you want to include `grpcurl` in a command pipeline, such as when using `jq` to +create a request body, you can use `-d @`, which tells `grpcurl` to read the actual +request body from stdin: +```shell +grpcurl -d @ grpc.server.com:443 my.custom.server.Service/Method <<