Applying different delays based on HTTP methodΒΆ

Let’s apply a delay of 2 seconds on responses to GET requests only made to echo.jsontest.com/b/c.

Run the following to create and export a simulation.

hoverctl start
hoverctl mode capture
curl --proxy localhost:8500 http://echo.jsontest.com/b/c
curl --proxy localhost:8500 -X POST http://echo.jsontest.com/b/c
hoverctl export simulation.json
hoverctl stop

Edit the simulation.json file so that the "globalActions" property looks like this:

1
2
3
4
5
6
7
8
9
      "globalActions": {
         "delays": [
            {
               "urlPattern": "echo\\.jsontest\\.com\\/b\\/c",
               "httpMethod": "GET",
               "delay": 2000
            }
         ]
      }

Now run the following to import the edited simulation.json file and run the simulation:

hoverctl start
hoverctl import simulation.json
curl --proxy localhost:8500 http://echo.jsontest.com/b/c
curl -X POST --proxy localhost:8500 http://echo.jsontest.com/b/c
hoverctl stop

You should notice a 2 second delay on the response to the GET request and no delay on the response to the POST request.