How do inject variables to WebStorm HTTP Client from code, not separate .env.json
?
Question about WebStorm, but actually it is related to HTTP Client plugin, which available in every JetBrains IDEA-based IDE. Someone calls it Rest client
.
I want to create a dynamic demo for the class. But requests are based on the local setup.
I manage for now clean up the usual configurations, that do not use additional variables. Everything has come from the .env
file and working as expected. But HTTP Client is like a completely separate program inside the IDE. It does not integrate with a project in any shape or form. It does not share run configuration. It does not use shell environment vars. Everyone in class needs to copy-paste the same info into a project and HTTP Client.
For example. Everyone in class has .env
file where he did set-up variable API-URL="localhost:8084"
and port is different. This is how their local rest server is set up.
Now, I am sharing example.rest
with everyone. For example:
### RestAPI
GET https://{{api_url}}
They should have ability to run it and get result. Only option I have - to create http-client.env.json
with
{
"dev": {
"api_url": "{{some public access url}}"
},
"local": {
"api_url": "localhost:8084"
}
}
And now each student need to change this env.json
file for local setup.
Problem - Duplicating vars between different files. Manual goverment of git changes for this file.
So, is there any way how to share data between a project and HTTP Client?
Thank you for your ideas!
Read documentation:
According to JetBrains staff, this is impossible and was done on purpose.
Their current vision - is that HTTP Client is a separate application and they avoid any further integration with main IDEs.
Links:
PS As the only possible solution for this moment - add popularity to JetBrains issue to introduce this kind of functionality - https://youtrack.jetbrains.com/issue/IDEA-314198/Allow-project-environment-injection-to-HTTP-Client