Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Redirect Input to receive raw payload request body #33

Open
talis-fb opened this issue Mar 2, 2024 · 0 comments
Open

Add Redirect Input to receive raw payload request body #33

talis-fb opened this issue Mar 2, 2024 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers 🐇 Small
Milestone

Comments

@talis-fb
Copy link
Owner

talis-fb commented Mar 2, 2024

The objective is to replicate this feature in HTTPie: https://httpie.io/docs/cli/redirected-input

Accept user for passing request data is through redirected stdin (standard input)—piping.
Receiving the inputs from this method is similar to using --raw flag with the content passed in stdin.

treq PUT api.com/put < files/data.json
echo -n '{"name": "John"}' | http PATCH api.com/patch Auth:None

These three command are equivalent (consider the file.json with content as {"name": "Thales"})

treq POST api.com/post --raw '{"name": "Thales"}'
echo '{"name": "Thales"}' | treq POST api.com/post
treq POST api.com/post < file.json
cat file.json | treq POST api.com/post

Additional Considerations:

It's really important use the same abstraction used by --raw flag. That way is even possible to merge the input from this with request items.

This command

echo '{ "name": "John", "age": 21 }' | treq POST api.com/post job=dev role=admin

would request with body...

{ 
  "name": "John",
  "age": 21,
  "job": "dev",
  "role": "admin"
}
@talis-fb talis-fb added this to the v1.3.0 milestone Mar 2, 2024
@talis-fb talis-fb added enhancement New feature or request good first issue Good for newcomers 🐇 Small labels Mar 2, 2024
@talis-fb talis-fb moved this to 📋 Backlog in TReq Tasks Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers 🐇 Small
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant