Skip to content

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.

Add Rule

Creating Rules

  1. Click the Add Rule button in the sidebar to create a new rule configuration.

  2. Configure the basic rule properties:

    • Rule name (for identification)
    • Description (optional)
    • Match pattern (the pattern to match against requests)
  3. 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

Match Type

  1. Choose a matching method:
    • Contains: Pattern exists anywhere in the target
    • Equals: Exact match required
    • Matches(Regex): Pattern interpreted as regular expression

Match Method

TIP

Use the Test Match Value feature to validate your pattern matching. A dialog will display the match results for verification.

Test Match Value

  1. Configure HTTP method filtering Select specific HTTP methods to filter requests by method type. Request Method Filter

  2. 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. Add Rules

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. Delete Rule

WARNING

Rule deletion cannot be undone. Please proceed with caution.

Test & Scripts

ApiTune provides powerful capabilities for API testing and script generation. Test&Print Scripts

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.

js
// 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.

Test Result

ApiTune supports customizable request logging.

Print Syntax

All print statements must be prefixed with at.print.

js
// 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.

Print Result