docs/en/docs/rules/rawfile.md
rawfile is an enhanced version of file. In addition to supporting all the features of file, it also allows you to define a complete HTTP response in a file, including:
pattern rawfile://value [filters...]
| Parameters | Description | Detailed Documentation |
|---|---|---|
| pattern | Expression to match against the request URL | Match Pattern Documentation |
| value | Operation content. Supports the following types: | |
| • Directory/File Path | ||
| • Remote URL | ||
| • Inline/Embedded/Values Content | Operation Instruction Documentation | |
| filters | Optional filters. Supports matching against: | |
| • Request URL/Method/Headers/Content | ||
| • Response Status Code/Headers | Filter Documentation |
/User/xxx/raw.txt
HTTP/1.1 500 OK
Content-Type: application/json
X-Custom-Header: value
{
"status": "success",
"data": "your content here"
}
https://www.example.com/test/rawfile tpl:///User/xxx/raw.txt
# Equivalent to
# https://www.example.com/test/rawfile file:///User/xxx/test.json replaceStatus://500 resType://json resHeaders://x-custom-header=value
# Supports remote URLs
# pattern rawfile://https://example.com/raw.json
https://www.example.com/test/rawfile Returns:
// 状态码
500
// 响应头
content-type: application/json
x-custom-header: value
content-length: 56
// 响应内容
{
"status": "success",
"data": "your content here"
}
For other functions, see: file