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 file based operator @ to insert value from files to request items #23

Open
talis-fb opened this issue Feb 19, 2024 · 0 comments
Open
Labels
enhancement New feature or request Medium Requires some effort and time
Milestone

Comments

@talis-fb
Copy link
Owner

The objective is to replicate this feature in HTTPie (https://httpie.io/docs/cli/file-based-separators).

The goal it is: instead of using a static string as the value for some header, you can use :@ operator to pass the desired value from a file.
Example, let's suppose I cd in a folder with a data.json file with content { "email": "...", "password": "..." } and a file "name.txt" with content as just Thales. You'll can...

treq POST httpbin.org/post \
    name=@name.txt               # Read a data field’s value from a file
    datas:=@data.json        # Embed a JSON object from a file
    X-Data:@files/another-file.txt             # Read a header from a file
    token==@files/token.txt             # Read a query parameter from a file

Additional Considerations:

This handler should live in input parsers to request data.

It must exist a function to receive input of "file path" and reader it, returning the String of content. This function would be called inside functions of parsers_request_items (that should pass to it the value they extracted from their input).

@talis-fb talis-fb added enhancement New feature or request Medium Requires some effort and time labels Feb 19, 2024
@talis-fb talis-fb added this to the v1.3.0 milestone Mar 2, 2024
@talis-fb talis-fb changed the title Add file based separators @ to insert value from files to request items Add file based operator @ to insert value from files to request items 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 Medium Requires some effort and time
Projects
Status: 🏗 In progress
Development

No branches or pull requests

1 participant