Huachao / vscode-restclient

REST Client Extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=humao.rest-client
MIT License
5.3k stars 440 forks source link

Common http header #909

Open fred214 opened 3 years ago

fred214 commented 3 years ago

The environmentVariables is quite useful that I can switch between different environment conveniently. But I have the same http headers cross different request, although I can put the these http header in the environmentVariables, but I still write key value in different request. Is there any approach that I can using one variable which contains the list of key values in different request?

opensas commented 2 years ago

Same situation here, I have quite a lot of request like this in the same file

GET {{url}}/c/contract
wb-key: {{api_key}}
Content-Type: application/json 

And I have to constantly repeat the headers

I'm not sure what would be the best approach, maybe some kind of settings that apply to the whole file, but it might be neccesary to have some way to remove those default for specific headers.

perhaps something like

@common-headers
wb-key: {{api_key}}
Content-Type: application/json 

###
GET {{url}}/c/contract
wb-key: {{api_key}}
Content-Type: text 

### headers could be overriden

###
POST {{url}}/c/authenticate
--wb-key: 
Content-Type: application/json 

(The -- means to remove the wb-key header for that particular request)

aktxyz commented 2 years ago

was about to open a suggestion for this very same file based common header idea ! this would really be great, I have headers I want on every request for this particular file ... but not for other files so the setting approach is not ideal

opensas commented 2 years ago

and also, I find it more explicit, easy to follow and better for using it as documentation to have everything on the same file