RequestInterceptorRule class
请求拦截规则模型 / Request interceptor rule model
用于定义网络请求的修改规则,支持:
- URL + Method 匹配
- 请求参数修改(headers、body)
- 响应参数修改(statusCode、headers、body)
Used to define modification rules for network requests, supporting:
- URL + Method matching
- Request parameter modification (headers, body)
- Response parameter modification (statusCode, headers, body)
Constructors
-
RequestInterceptorRule({required String id, required String name, required String urlPattern, String method = '', bool enabled = true, bool useRegex = false, Map<
String, String> ? requestHeaders, dynamic requestBody, int? responseStatusCode, Map<String, String> ? responseHeaders, dynamic responseBody})
Properties
- enabled → bool
-
是否启用 / Whether enabled
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → String
-
规则唯一ID / Rule unique ID
final
- method → String
-
HTTP方法(GET、POST、PUT、DELETE等,为空则匹配所有方法)
HTTP method (GET, POST, PUT, DELETE, etc., empty matches all)
final
- name → String
-
规则名称 / Rule name
final
- requestBody → dynamic
-
请求体修改(为空则不修改)/ Request body modification
final
-
requestHeaders
→ Map<
String, String> ? -
请求头修改(键值对,为空则不修改)/ Request headers modification
final
- responseBody → dynamic
-
响应体修改(为空则不修改)/ Response body modification
final
-
responseHeaders
→ Map<
String, String> ? -
响应头修改(键值对,为空则不修改)/ Response headers modification
final
- responseStatusCode → int?
-
响应状态码修改(为空则不修改)/ Response status code modification
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- urlPattern → String
-
URL匹配模式 / URL matching pattern
final
- useRegex → bool
-
是否使用正则匹配URL / Whether to use regex for URL matching
final
Methods
-
copyWith(
{String? id, String? name, String? urlPattern, String? method, bool? enabled, bool? useRegex, Map< String, String> ? requestHeaders, dynamic requestBody, int? responseStatusCode, Map<String, String> ? responseHeaders, dynamic responseBody}) → RequestInterceptorRule - 创建副本 / Create a copy
-
matches(
String url, String method) → bool -
判断是否匹配指定的请求 / Check if matches the specified request
url请求URL / Request URLmethod请求方法 / Request method -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited