For the complete documentation index, see llms.txt. This page is also available as Markdown.

Useful helper functions

Leverage useful helper functions within Hoverfly Cloud's templating engine to simplify and enhance your API simulations.

Concatenate two strings

{{ concat '<string1>' '<string2>' }}

Search and replace text in a string

{{ replace '<string-to-search>' '<string-to-replace>' '<replacement-string>' }}

Create an array from a delimited string

This can be particularly useful when dealing with the results of a JSONPath query that returns an array, as these are space delimited strings of values.

{{ split '<delimited-string>' '<delimiter>' }}

Change the HTTP response code

If you are following a pattern where you want a single request/response pair to return different HTTP response codes based on the outcome of logic, then you can do that using the following function:

{{ setStatusCode <any-valid-http-response-code> }}

Set the value of an HTTP response header

You can set the value of an HTTP header dynamically from script:

{{ setHeader '<header-name>' '<new-value>'}}

Last updated