# whistle.rules

> rules plugin for whistle

Latest version **0.1.0** (published 2017-05-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install whistle.rules
pnpm add whistle.rules
yarn add whistle.rules
bun add whistle.rules
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2017-05-17 |
| First published | 2017-05-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | avenwu |
| Maintainers | avwu |
| Keywords | whistle, rules, file |

## Links

- npm: https://www.npmjs.com/package/whistle.rules
- Repository: https://github.com/whistle-plugins/whistle.rules
- Issues: https://github.com/whistle-plugins/whistle.rules/issues
- npm.io page: https://npm.io/package/whistle.rules

## Dependencies (2)

- [express](https://npm.io/package/express.md) ^4.15.2
- [body-parser](https://npm.io/package/body-parser.md) ^1.17.1

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 0.1.0 (latest) — 2017-05-17
- 0.0.5 — 2017-05-17
- 0.0.4 — 2017-05-14
- 0.0.3 — 2017-05-13
- 0.0.2 — 2017-05-13

## README

# whistle.rules

可以通过请求头字段和指定的本地文件设置whistle规则的插件。

# 安装
1. 安装最新版的[whistle](https://github.com/avwo/whistle)。

   npm install -g whistle

   	# Mac、Linux用户可能需要加sudo
   	sudo npm install -g whistle



3. 安装rules插件：

   npm install -g whistle.rules

   	# Mac、Linux用户可能需要加sudo
   	sudo npm install -g whistle.rules

# 使用
1. 通过请求头字段 `x-whistle-rules` 和 `x-whistle-values` 分别设置Rules和Values，这两个字段得值都要进行 `encodeURIComponent`:

   ```
   var rules = encodeURIComponent('www.test.com 127.0.0.1:8899\nresHeaders://{test}');
   var values = encodeURIComponent(JSON.stringify({
   	test: {
   	'x-test1': 1,
   	'x-test2': 2
   	}
   }));
   req.headers['x-whistle-rules'] = rules;
   req.headers['x-whistle-values'] = values;
   ```

2. 自动加载本地指定文件的规则，如果指定的本地文件发生修改会自动重新加载，默认文件为 `~/whistle.rules.txt` ，可以通过插件的界面修改路径(如果whistle是 `v1.4.2` 及以上版本，也可以通过启动参数 `extra`指定 `rules=/User/xxx/xxx.txt` extra的优先级低于通过界面配置)，具体见whistle的界面中plugins的rules Option。

# License

[MIT](https://github.com/whistle-plugins/whistle.rules/blob/master/LICENSE)

---
_Source: https://npm.io/package/whistle.rules · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
