Skip to content

Commit 8e94e72

Browse files
authored
Merge pull request #7 from vearne/feat/header
support for using variables in the header
2 parents 9183cc6 + 6825a6a commit 8e94e72

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ autotest extract --xpath=${XPATH} --json=${JSON}
4545
## Example
4646
### 1) start a fake http api service
4747
```
48-
cd docker-compose
48+
cd ./docker-compose
4949
docker compose up -d
5050
```
5151
#### Add

README_zh.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ autotest extract --xpath=${XPATH} --json=${JSON}
4343
## 示例
4444
### 1) 启动一个伪造的http api服务
4545
```
46-
cd docker-compose
46+
cd ./docker-compose
4747
docker compose up -d
4848
```
4949
#### 添加

internal/command/http_call.go

+13-4
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,25 @@ func (m *HttpTestCallable) Call(ctx context.Context) *executor.GPResult {
137137

138138
func render(req config.Request) (config.Request, error) {
139139
var err error
140-
// body
141-
req.Body, err = templateRender(req.Body)
140+
// url
141+
req.URL, err = templateRender(req.URL)
142142
if err != nil {
143143
return req, err
144144
}
145145

146-
// url
147-
req.URL, err = templateRender(req.URL)
146+
// headers
147+
for i := 0; i < len(req.Headers); i++ {
148+
req.Headers[i], err = templateRender(req.Headers[i])
149+
if err != nil {
150+
return req, err
151+
}
152+
}
153+
154+
// body
155+
req.Body, err = templateRender(req.Body)
148156
if err != nil {
149157
return req, err
150158
}
159+
151160
return req, nil
152161
}

0 commit comments

Comments
 (0)