添加 http-client

This commit is contained in:
light
2020-01-13 20:05:35 +08:00
parent 9c7433663d
commit 6dd7d4047c
12 changed files with 160 additions and 0 deletions
+88
View File
@@ -0,0 +1,88 @@
# HTTP-Client-Editor of jetbrains
## 环境描述文件
- http-client.private.env.json 存储敏感信息的环境文件
```json
{
"env1": {"auth": ""},
"env2": {
"auth": "",
"key": ""
}
}
```
- http-client.env.json 存储普通信息的环境文件
```json
{
"env1": {
"base_url": ""
},
"env2": {}
}
```
## 请求描述文件
- *.http
```http
### (#)
# get
GET {{base_url}}/first
Authorization: Basic {{auth}}
```
```http
### post
POST {{base_url}}/second
Accept: application/json
> {%
client.log(response.body)
%}
```
- 变量由{{}}给出
1. 由环境描述文件给出, 如{{auth}},{{base_url}}
2. 由特定函数给出,如[{{$timestamp}} {{$uuid}} {{randomInt}}](https://www.jetbrains.com/help/idea/http-client-in-product-code-editor.html#dynamic-variables)
3. 由[返回处理脚本](https://www.jetbrains.com/help/idea/http-client-in-product-code-editor.html#)给出
```bash
> {%
client.log(response.body)
client.global.set("id", response.body.data[0].id)
# 设置环境变量id
%}
```
```bash
> ./temp.js
```
## 执行
- 在每个请求左侧有个绿色箭头 可以选择执行环境, .json 和 .http 在同一目录下
![image-20200112231911921](/Users/light/workspace/mynote/jetbrains/image-20200112231911921-8842506.png)
- 编辑窗口顶部,点击Run All Requests in File 会顺序执行所有请求
![image-20200112232328295](/Users/light/workspace/mynote/static/img/image-20200112232328295.png)
+19
View File
@@ -0,0 +1,19 @@
let mapleader="\"
set hlsearch
set incsearch
set ignorecase
set smartcase
set showmode
set number
set relativenumber
set scrolloff=3
set history=100000
nmap q :q<CR>
nmap Q :qa!<CR>
nnoremap <leader>[ :action PreviousTab<CR>
nnoremap <leader>] :action NextTab<CR>
"nnoremap [ ^
nnoremap & $
Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB