Start a virtual service from an example simulation

You can start your first virtual service with a pre-loaded example simulation file by following these steps:

  1. On your Dashboard, click the "Add" button. An "Add service" dialog box will pop up.

  2. Enter a service name, for example my-test-service.

  3. Select example-simulation from the drop down and click "Confirm".

Hoverfly Cloud provisions a dedicated Hoverfly container and assigns a DNS name for your service (in the form of <service-name>-<id>.hoverfly.io). The service is ready to use when the green tick-mark appears next to the service in the dashboard.

Click on the allocated URL, and you should see the following screen.

Congratulations! You have now got a highly configurable virtual service that you can share and use wherever you want.

If you look at the Dashboard, you will see that the test service is running and using the example simulation:

If you open the example-simulation by clicking on the simulation "example-simulation", you can then edit the endpoints to make the API simulation do whatever you please.

  1. From within the simulation editor, click Add endpoint, and then change the new endpoint to respond to Get methods.

  2. Add a Path Request matcher, so that this endpoint will respond to a path of /myapi/* using a Glob match - which is a wildcard. So any path that starts with /myapi/ will match.

  3. Add a response body of Hello {{ Request.Path.[1] }}

  4. Make sure to click Enable templating. This will allow Hoverfly to process the commands in the {{ handlebar }} syntax.

  5. Your simulation should be configured as in the image below. Click Apply changes, and you will be returned to the Dashboard.

  6. Now go back to the allocated URL, and add a path of /myapi/<your-name-here>

  7. You should get a greeting from your API

For more in-depth tutorials please visit the Tutorials section.

Last updated