Proxy Rules
Proxy rules in ApiTune provide powerful request interception and manipulation capabilities. You can create sophisticated rules to redirect traffic, modify requests/responses, or simulate various network conditions.
Creating Rules
Click the Add Rule button in the sidebar to create a new rule configuration.
Configure the basic rule properties:
- Rule name (for identification)
- Description (optional)
- Match pattern (the pattern to match against requests)
Select the match type from three options:
- URL: Matches against the complete URL
- Host: Matches against the hostname portion
- Path: Matches against the URL path portion
- Choose a matching method:
- Contains: Pattern exists anywhere in the target
- Equals: Exact match required
- Matches(Regex): Pattern interpreted as regular expression
TIP
Use the Test Match Value feature to validate your pattern matching. A dialog will display the match results for verification.
Configure HTTP method filtering Select specific HTTP methods to filter requests by method type.
Apply Rules Use the Add Rules dropdown to apply one or more manipulation rules. Multiple rules can be combined to create complex request/response modifications.
Rule Management
Enable/Disable Rules
Toggle rules on/off instantly using the enable/disable controls.
Rule Groups
Organize rules into logical groups using the rule group management features.
Rule Deletion
Remove rules when no longer needed via the delete function.
WARNING
Rule deletion cannot be undone. Please proceed with caution.
Test & Scripts
ApiTune provides powerful capabilities for API testing and script generation.
Access these features through the Test&Scripts tab.
The right panel contains pre-built test and print snippets. Insert them into your editor with a single click.
Test Syntax
All test code must be prefixed with at.test
.
// Test definition syntax
at.test(title: string, fn: () => {
// Test implementation
})
// Example
at.test('Request body validation', function() {
const body = JSON.parse(request.body)
expect(body.result).to.equal('success')
})
INFO
ApiTune integrates Chai assertion library. Reference the complete Expect API for available assertions.
Tests execute automatically for each matching request. View results in the test tab.
Print Syntax
ApiTune supports customizable request logging.
All print statements must be prefixed with at.print
.
// Basic logging
at.print(log: string)
// Log levels
at.print.debug('Debug message')
at.print.info('Info message')
at.print.log('Standard log')
at.print.warn('Warning message')
at.print.error('Error message')
// Advanced logging example
const list = []
for(let header of Object.keys(response.headers)) {
list.push({
value: `Response Header: ${header} => ${response.headers[header]}`,
type: 'log'
})
}
// List-style output
at.print.list(list);
View logging output in the print tab.