Rule Syntax
Whistle modifies requests/responses through simple rule configurations. The basic syntax structure is as follows:
pattern operation [lineProps...] [filters...]Rule Components
Each rule consists of three core components:
Matching Pattern (
pattern): An expression that matches request URLs, supporting multiple formats:- Domain matching:
www.test.com(matches all requests for this domain, including ports) - Path matching:
www.test.com/path - Regular expression:
/^https?://test\.com//i - Wildcards:
*.test.com,**.test.com/path
Whistle supports three URL types:
- Tunnel Proxy:
tunnel://domain[:port] - WebSocket:
ws[s]://domain[:port]/path/to - Regular HTTP/HTTPS:
http[s]://domain[:port]/path/to
- Domain matching:
Operation Directive (
operation), format:protocol://valueprotocol: The operation type, such as:reqHeaders: Modify request headersresHeaders: Modify response headers
value: The operation content, supporting multiple data sources:- Inline value:
reqHeaders://x-proxy-by=whistle(directly adds a request header) - Local file:
file://path/to/file - Remote resource:
https://example.com/data.json - Preset variable:
{key}(read from embedded values in Rules or from Values)
- Inline value:
The
protocol://part in operation can be omitted in the following two scenarios:iporip:port: equivalent tohost://iporhost://ip:portD:\path\to,/path/to, or{key}: equivalent tofile://D:\path\to,file:///path/to, orfile://{key}
Additional Configuration (Optional) (
lineProps): Additional settings that apply only to the current rule, used to increase rule priority, refine matching functions, and other behaviors (supports combination). For details, see lineProps.Filter Conditions (Optional) (
includeFilter/excludeFilter):- Logical relationship: Multiple conditions follow an "OR" matching logic; the filter is satisfied if any one condition matches.
- Matching scope:
- Request: URL, method (GET/POST, etc.), header fields, content, client IP
- Response: Status code, header fields, content, server IP
Advanced Rule Configuration
- Combined Configurationtxt
pattern operation1 operation2 ... [includeFilter://pattern1 ... excludeFilter://patternN ...] - Reversing Positions (
pattern1andoperationmust not both be URLs or domain names)This means they must not both be URLs or domain names like
https://test.com/path,//test.com/path,test.com/path, ortest.com.txtoperation pattern1 pattern2 ... [includeFilter://pattern1 ... excludeFilter://patternN ...] - Line Break Configurationtxt
line` operation pattern1 pattern2 ... [includeFilter://pattern1 ... excludeFilter://patternN ...] `Whistle will automatically replace line breaks within code blocks with spaces.