天天看點

css中.prepend,cssPrepend

cssPrepend

往content-type為html或css的響應内容前面追加資料,如果是html,則會自動加上 style 标簽再追加到響應内容前面,如果是css,則會自動追加到文本前面,這個與resPrepend的差別是resPrepend不區分類型,對所有比對的響應都會追加指定的資料,配置方式:

pattern cssPrepend://filepath

filepath為Values裡面的{key}或者本地檔案(如:e:\test\xxx、e:/test/xxx、/User/username/test/xxx等),pattern參見比對模式,更多模式請參考配置方式。

例子:

www.ifeng.com cssPrepend://{test.css}

test.css:

html, body {background: red!important;}

過濾規則

需要確定whistle是最新版本:更新whistle

如果要過濾指定請求或指定協定的規則比對,可以用如下協定:

ignore:忽略指定規則

filter:過濾指定pattern,支援根據請求方法、請求頭、請求用戶端IP過濾

例子:

# 下面表示比對pattern的同時不能為post請求且請求頭裡面的cookie字段必須包含test(忽略大小寫)、url裡面必須包含 cgi-bin 的請求

# 即:過濾掉比對filter裡面的請求

pattern operator1 operator2 excludeFilter://m:post includeFilter://h:cookie=test includeFilter:///cgi-bin/i

# 下面表示比對pattern1、pattern2的請求方法為post、或請求頭裡面的cookie字段不能包含類似 `uin=123123` 且url裡面必須包含 cgi-bin 的請求

operator pattern1 pattern2 includeFilter://m:post excludeFilter://h:cookie=/uin=o\d+/i excludeFilter:///cgi-bin/i

# 下面表示比對pattern的請求忽略除了host以外的所有規則

pattern ignore://*|!host

# 下面表示比對pattern的請求忽略file和host協定的規則

pattern ignore://file|host