Our base version of the extension works as a customizable API mock server in a browser extension that allows you to effortlessly mock HTTP requests by defining a set of rules that may capture HTTP requests in your application and return a mocked response. tweak listens for outgoing HTTP requests to match them against your rules. If there's a match, tweak will re-write the request for you.
Here's how the extension looks like.
- Search on/off: read more about the requests autocomplete functionality.
- Delete all: deletes all the rules and the request autocomplete cache. Re-trigger in the browser tab the requests that you wish to search in the URL field.
- Collapse all rows: minimizes all the rows.
- Run/Pause the extension: click on the run button when you are ready to start intercepting requests. You can also achieve this through a shortcut. From the moment you activate the extension all active rules are enforced on that browser tab.
- Create a new rule: adds a new empty rule.
You can use the export functionality to save rules. You can later on import the same rules into some other browser or device, or share them with a colleague.
URL and label
The URL field is a critical piece of a tweak rule. Here's how URL request matching works in tweak:
- String partial matching (default) is applied by default, meaning that if you type
/v1/userin the URL field, and the following HTTP requests take place:
//api.com/v1/user/456, both requests are matched. For example
//api.com/v2/user/123would not match.
- Regular expression toggle, when enable at the rule level, the extension considers the input of the URL a regular expression, meaning that if you type
.*\/v1\/user\/\d\d$in the URL field, the following HTTP requests
//api.com/v1/user/173, are matched.
When writing a description under the label text field it will be reflected on top of the URL input field. This will allow you to quickly differentiate the various rules you might have in the extension, since it's visible even if the rule is collapsed.
Regular expression toggle
As mentioned above ☝️, when toggled on, you can specify a regular expression to match against the request URL. Don't worry about typos, we will give you instant feedback on whether your regular expression is valid or not.
Number of requests intercepted
The number of requests intercepted by a given row are reflected in the counter near the activation toggle. This serves only as an indicator, it can also help you understand how many times that request was triggered by the page. Additionally, when intercepting requests the timestamp of the last request intercepted by a given row is displayed in the counter tooltip.
If you're seeing the
0 value after trying to intercept a request it means that you might have a mismatch on your rule. Double check the request URL and the selected HTTP method to ensure everything is ok.
More options & actions
Certain actions to manipulate rules such as delete or duplicate a rule can be accessed through this icon. The actions are:
- Delete an item
- Duplicate an item
- Move an item to the top of the panel
- Move an item to the bottom of the panel
Write here the HTTP status code you want for your response.
In this field you can introduce artificial delays on the resolution of a given request(s). We wrote this blog post to explain this feature in detail.
In this area you can specify the following:
- Response payload
- Request payload
- Response & request headers
- Response hook (only available on paid plans)
The response editor adapts to the type of content indicated via
content-type header under the response headers tab. Here are the supported languages:
- JSON - most of the times, developers deal with JSON data. If the
json, the JSON language will be enabled in the editor.
- For all other use cases, the editor falls back to plain text.