Git Product home page Git Product logo

Comments (8)

jhump avatar jhump commented on June 27, 2024

I think that's reasonable. But it could conflict with reading the request body from stdin. I think maybe the logic should look like so:

  1. If only headers are read from stdin, then read stdin, line-by-line. Each line must be a header in name: value form. Blank lines are ignored as are lines that start with a # (I'm a sucker for allowing comments if/when it's easy to support!). It probably needs to trim, too -- though maybe only trim from the left (to avoid leading whitespace in the header name, but allow trailing whitespace in the value?).
  2. If only the request is read from stdin, then the current behavior should be preserved.
  3. If both are to be read from stdin, it should have the headers first, one per line, and then a blank line, and then the request body (much like an HTTP 1.1 request might look).

What do you think? I doubt I'll have time to implement this soon, but I'll accept a patch if you're up for this.

from grpcurl.

jhump avatar jhump commented on June 27, 2024

Actually, I just had a thought: what if instead we added a flag that allowed header values to be re-written via environment variable interpolation?

So instead of having to feed the headers in via stdin, you could do something like so:

grpcurl -expand-headers -H 'name: ${value}'

Note use of single quotes, so the shell won't expand ${value}. Instead, grpcurl could do that, by search for ${...} sequences and replacing them with the corresponding environment variable.

What do you think about that? I can actually see cases where both would be useful -- ability to interpolate env vars into the values and ability to pass via stdin... Anyhow, I think I'd take a patch that had either (or both!) of these approaches implemented.

from grpcurl.

jammerful avatar jammerful commented on June 27, 2024

Thanks for the second solution, I think that is much simpler and I'll put a PR in for that.

from grpcurl.

jammerful avatar jammerful commented on June 27, 2024

I'll have a PR opened shortly, already have the patch ready.

After putting in the PR, I would need a new release cut and build artifacts published. Is this possible?

from grpcurl.

jammerful avatar jammerful commented on June 27, 2024

@jhump Thanks for merging my PR, is there anyway you can cut a new release with accompanying binaries?
Also should we close this issue, or should we leave it open for also accepting headers from stdin?

from grpcurl.

jhump avatar jhump commented on June 27, 2024

@jammerful, we can leave this issue open as an enhancement request to also accept via stdin.

I should be able to do a release soon, early next week at the latest. I'm looking for other issues that I might be able to address, too, just so it's not such a small release.

from grpcurl.

jammerful avatar jammerful commented on June 27, 2024

@jhump Thanks, let me know if I can help at all.

from grpcurl.

jhump avatar jhump commented on June 27, 2024

@jammerful, FYI, a new v1.4.0 has been released that includes the change you landed.

from grpcurl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.