curlz
curlz copied to clipboard
http language: dynamic variables
Extension to the http language file format #5
Request with dynamic variables in the body.
This feature should be behind a feature flag for the IntelliJ flavor --flavor intellij.
The marking symbol for a dynamic variable is the $ that is prefixed to the variable name.
IntelliJ's HTTP Client docs are 11 variables defined.
Special cases
{{ $processEnv envVarName }}: allows the resolution of a local machine environment variable to a string value. E.g. theUSERNAMEvariable:GET https://httpbin.org/get?user={{ $processEnv USERNAME }}
Example 1
### Send request with dynamic variables in request's body
POST https://httpbin.org/post
Content-Type: application/json
{
"id": {{$uuid}},
"price": {{$randomInt}},
"ts": {{$timestamp}},
"value": "content"
}
Example 2
The alternative approach is to call the functions that are bound to the dynamic variables directly:
### Send request with dynamic variables in request's body
POST https://httpbin.org/post
Content-Type: application/json
{
"id": {{ uuid() }},
"price": {{ randomInt() }},
"ts": {{ timestamp() }},
"value": "content"
}