Skip to content
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

http language: dynamic variables #17

Open
sassman opened this issue Jan 7, 2023 · 0 comments
Open

http language: dynamic variables #17

sassman opened this issue Jan 7, 2023 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers
Milestone

Comments

@sassman
Copy link
Member

sassman commented Jan 7, 2023

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. the USERNAME variable:
    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"
}
@sassman sassman added the enhancement New feature or request label Jan 7, 2023
@sassman sassman added this to the http language milestone Jan 7, 2023
@sassman sassman added the good first issue Good for newcomers label Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant