JetBrains / JetBrains/http-request-in-editor-spec

[propose] Named access to HTTP response

Open
#10 1 comment 1 reaction 0 assignees View on GitHub
Follow Youtrack Issue
Dominant language
No language data
Stars
152
Forks
12
PR merge metrics
No merged PRs in 30d

Description

# Request

Ability to refer to HTTP response data by name.

# Implementation

A fellow named Huachao Mao wrote an amazing HTTP client for VSCode from which we can get some inspiration: https://github.com/Huachao/vscode-restclient

His HTTP client allows binding a variable name to an HTTP request, so that the HTTP response becomes accessible via that name. It uses the syntax `@name variable_name` in a comment in the scope of the HTTP request.

Example:

```
###
# @name bananas
GET http://localhost/greeting

###
POST http://localhost/something/{{bananas.response.body.foo}}

{
"message": "{{bananas.response.body.greeting}}"
}
```

The example above assumes that:

1. `GET http://localhost/greeting` returns `{ "foo": 123, "greeting": "hello" }`
2. The content type is `application/json` so that the response is automatically parsed as JSON

The rest is self-explanatory.

Once the response is received, it binds the response object to the `bananas` variable name.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.