davidnussio / vscode-jq-playground

Visual Code Studio jq playground
https://marketplace.visualstudio.com/items?itemName=davidnussio.vscode-jq-playground
MIT License
46 stars 8 forks source link

Add ability to specify custom HTTP headers for the URLs in the jq page #51

Closed alex-y-kozlov closed 3 years ago

alex-y-kozlov commented 4 years ago

Most of APIs returning JSON are protected with API token that's passed via custom HTTP header. Being able to specify these headers curl-style (-H or similar) would make much more useful current ability to specify URL of hte JSON

davidnussio commented 4 years ago

Yes ... I also want to work on this problem. I just opened #30 some time ago ... I have to decide how to implement it: curl style, httpie or follow rfc2616. I hope to work on this problem soon

alex-y-kozlov commented 4 years ago

httpie seems to be a good fit. in your syntax http is implicit and everything else follows the url

davidnussio commented 4 years ago

I didn't have much time and I need to works with http request with auth token too. I chose to run the programs present in the system path and let the user use his favorite tool.

jq '.'
$ http http://httpbin.org/get "Authorization: Bearer 1234abcd"

jq '.'
$ curl -X GET http://httpbin.org/get -H "Authorization: Bearer 1234abcd"

jq '.'
$ wget -qO- http://httpbin.org/get --header "Authorization: Bearer 1234abcd"

# It could be used with others tools
jq --raw-input '.'
$ cat /etc/issue

It's not bad as starting point. There are some caveats but as first working solution... is only few lines of code. I test a little bit then will release it

davidnussio commented 3 years ago

I released an experimental version with support of command line.

Screenshot 2021-02-14 114736