Mock response body
This is an example of alteration rule among many others. You can explore all rules available at Settings
> Manage rules
> Add a new rule
.
Mocking response body is made through adding a rule with a mock response body
action. You can referer to modifying traffic with rules for more information about rules.
Open rule management in one of the following ways:
- Settings menu > manage rules
- Status bar > active rule
Ctrl+T
orCmd+T
to access the search everywhere tool, then typeManage rules
Click on
Add a new rule
buttonSearch for
mock response
and select itAt this point you should have the following dialog box:
- Fill the form:
- Status Code : The desired status code for the response (200 for this example)
- Content type: Choose the content-type from the list (for this example,
json
). Leave it to unknown if you want Fluxzy to detect the content type from the provided body. - Body type: Choose how the request body will be retrieved (for this example,
FromString
)FromString
: The body will be taken from the provided string, for this sample will be{"message": "Hello world"}
FromImmediateArray
: The body will be taken from the provided base64 stringFromFile
: The body will be taken from the provided file name
- Add additional response header you want to send to the client
- Choose a filter. The specified action will only be applied to requests that match the filter. For this example, we will choose
Select filter
andFull url filter
and fill withhttps://test-mock.com
.
Save everything, now the rule should appear on rule management dialog
Now, any request to https://test-mock.com
will have a response with status code 200
and a body containing {"message": "Hello world"}
.