fullstorydev / grpcurl

Like cURL, but for gRPC: Command-line tool for interacting with gRPC servers
MIT License
10.36k stars 497 forks source link

How to add headers / metadata in the request #352

Closed ironhide0396 closed 1 year ago

ironhide0396 commented 1 year ago

I have gone through the docs and README as well , but could not find an option to add headers/metadata in the requests along with the data . Is this documented somewhere deep and missed by me ?

jhump commented 1 year ago

grpcurl -help describes all of the command-line options.

In particular, here are options relevant to setting request metadata:

  -H value
        Additional headers in 'name: value' format. May specify more than one
        via multiple flags. These headers will also be included in reflection
        requests to a server.

-expand-headers
        If set, headers may use '${NAME}' syntax to reference environment
        variables. These will be expanded to the actual environment variable
        value before sending to the server. For example, if there is an
        environment variable defined like FOO=bar, then a header of
        'key: ${FOO}' would expand to 'key: bar'. This applies to -H,
        -rpc-header, and -reflect-header options. No other expansion/escaping is
        performed. This can be used to supply credentials/secrets without having
        to put them in command-line arguments.

-reflect-header value
        Additional reflection headers in 'name: value' format. May specify more
        than one via multiple flags. These headers will *only* be used during
        reflection requests and will be excluded when invoking the requested RPC
        method.
  -rpc-header value
        Additional RPC headers in 'name: value' format. May specify more than
        one via multiple flags. These headers will *only* be used when invoking
        the requested RPC method. They are excluded from reflection requests.
ironhide0396 commented 1 year ago

Raised a PR here to update the README to reflect the same with a basic example. Might help others :) https://github.com/fullstorydev/grpcurl/pull/353