Skip to content

Commit 1100fd9

Browse files
authored
Merge pull request #238 from SpectoLabs/hoverctl-templates
Added examples for request templates
2 parents 5e3c81e + 34a4cbd commit 1100fd9

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Request Templates
2+
This is an example of a request template. This request template allows Hoverfly to serve a response to a partially matched request.
3+
4+
In this example, two templates are used for matching. The first will match a GET request to specto.io/virtualized. The second will match any request that includes the header "Match: true".
5+
6+
To import these templates into Hoverfly, you can run the following command:
7+
```
8+
hoverctl templates <path to file>
9+
```
10+
To see all request templates configured in Hoverfly, use the following command:
11+
```
12+
hoverctl templates
13+
```
14+
To find out more, please check the documentation regarding [partial matching](https://spectolabs.gitbooks.io/hoverfly/content/usage/matching_requests.html)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"data": [{
3+
"requestTemplate": {
4+
"path": "/virtualized",
5+
"method": "GET",
6+
"destination": "specto.io"
7+
},
8+
"response": {
9+
"status": 201,
10+
"encodedBody": false,
11+
"body": "<h1>This page is virtualized</h1>"
12+
}
13+
}, {
14+
"requestTemplate": {
15+
"headers": {
16+
"Match": ["true"]
17+
}
18+
},
19+
"response": {
20+
"status": 200,
21+
"body": "<h1>Your request has been matched</h1>"
22+
}
23+
}]
24+
}

0 commit comments

Comments
 (0)