Currently, grpcurl accept data input with -d string option.
We can set request content directly to string part.
If the value is '@', request contents are read from stdin.
grpcurl -d "{\"name\":\"sample user\"}" -proto ./helloworld.proto localhost:50051 sample.Greeter/SayHello
or
// get contents from stdin with '@' or '@-' (curl command's style)
grpcurl -d @- -proto ./helloworld.proto localhost:50051 sample.Greeter/SayHello <<EOM
> {"name":"sample user"}
> EOM
or
// file paths can be set just after '@'
grpcurl -d @request_content.json -proto ./helloworld.proto localhost:50051 sample.Greeter/SayHello
Then, we can write the same logic shown above simply.
Currently, grpcurl accept data input with
-d string
option. We can set request content directly tostring
part. If the value is '@', request contents are read from stdin.So, we can set request content like this
In this format, we have to keep options and file paths in different variables when writing some jobs in shell script. For example,
So, I think the following format is better. This format is the same as
curl
command (https://man7.org/linux/man-pages/man1/curl.1.html)Then, we can write the same logic shown above simply.