Skip to content

generated curl command inlines file on the CLI instead of referencing payload #203

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

Closed
teto opened this issue Jun 6, 2023 · 3 comments
Closed

Comments

@teto
Copy link
Collaborator

teto commented Jun 6, 2023

I realized with #202 that shows the curl command used that
< {{TEST_DATA_FOLDER}}/payloads/v2/model.json translates to --data-raw HUGE STRING instead of referencing a file. I am not sure if that's a plenary fault and if we can fix that on our side.
I dont know either if this should be configurable (on a per-request basis for instance) but for my scenarios I would rather have the curl command reference the file on the filesystem with curl --data-raw @file.txt rather than curl --data-raw <INLINED FILE.TXT>

@teto
Copy link
Collaborator Author

teto commented Jun 6, 2023

after looking into lua/rest-nvim/request/init.lua , seems like it's our fault: we load the file in memory to be able to replace variables but never write the generated result back.
In a way it would be nice to distinguish between files where we want to replace values and files we dont need to. This could speed up request. This can be done in several ways:

  1. do the replacing just for json ? it looks ok to me but it's a breaking change plus it may make sense for some other format like .txt. Maybe we should limit the replacing for textual formats aka json/etc
  2. make it controllable via a new symbol aka << instead of < or <readonly to mark that it's not a template file ?

cc @NTBBloodbath

NB: if we do change the format, it could be interesting to follow hurl's format #195 but seems like they dont have the templating feature of rest.nvim so it doesn't make sense yet.

@teto
Copy link
Collaborator Author

teto commented Jul 11, 2023

not tested much but here is an implem #216 : if you reference a file via <@ file instead of < file the filename will be passed as is to curl, thus making the curl command a ton shorter

@flexagoon
Copy link
Contributor

rest.nvim no longer has the option to generate curl commands, so this issue is no longer relevant

@teto @NTBBloodbath

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants