% Symbol Usage
The plugin management interface allows you to intuitively configure various parameters. For example, you can enable the whistle.autosave plugin to support the following configurations:
- Enable storage of captured packet data
- Configure the directory for storing captured packet data
In addition to the management interface, you can also use the % symbol directly in the rule file for quick configuration.
Global configuration (applies to all requests)
%autosave=123
%autosave.enableAutoSave=true
%autosave.storageDir=/User/xxx/test/sessionsFine-grained configuration (for specific requests)
www.test.com/api %autosave=abc
www.test.com/api %autosave.enableAutoSave=false [filters...]
www.test.com/api %autosave.storageDir= [filters...]Retrieving plugin variable values
In plugin hooks, you can retrieve the configured variable list using the following code:
req.originalReq.globalPluginVars; // Global variables, such as ['123', 'enableAutoSave=true', 'storageDir=/User/xxx/test/sessions']
req.originalReq.pluginVars; // Variables for fine-grained configuration, such as ['abc', 'enableAutoSave=false', 'storageDir=']Enable automatic rule prompts
If the configuration items via plugin variables are fixed, you can configure optional options in the whistleConfig field in the plugin's package.json, so that automatic prompts can be added to the rules:
Anonymous Key Value Hints
{
"name": "@scope/whistle.test-plugin-vars",
...
"whistleConfig": {
"pluginVars": {
"hintList": [
"test1",
"test2",
"test3"
]
}
},
...
}
Value and display content separated:
{
"name": "@scope/whistle.test-plugin-vars",
...
"whistleConfig": {
"pluginVars": {
"hintList": [
{
"text": "test1",
"displayText": "displayText1"
},
{
"text": "test2",
"displayText": "displayText2"
},
{
"text": "test3",
"displayText": "displayText3",
"help": "https://www.example.com/path"
}
]
}
}
...
}Both
displayTextandhelpare optional. When configuringhelp: Help Link, when the hint is selected, pressF1on the keyboard. key automatically opens the help link

Setting the Key Name
{
"name": "@scope/whistle.test-plugin-vars",
...
"whistleConfig": {
"pluginVars": {
"hintList": [
{
"text": "test1",
"displayText": "displayText1"
},
{
"text": "test2",
"displayText": "displayText2"
},
{
"text": "test3",
"displayText": "displayText3",
"help": "https://www.example.com/path"
}
],
"hintSuffix": [
"=",
".key1=123",
".key2"
]
}
}
...
}
Selecting %test-plugin-vars= will automatically display the contents of hintList:

Using the backend interface
{
"name": "@scope/whistle.test-plugin-vars",
...
"whistleConfig": {
"pluginVars": {
"hintSuffix": [
"=",
".key1=123",
".key2"
],
"hintUrl": "/cgi-bin/plugin-vars"
}
}
...
}
hintListandhintUrlThey are mutually exclusive; only one can be used at a time.hintSuffixis optional.


For the implementation of /cgi-bin/plugin-vars, refer to the Plugin Development Documentation