From e4eee420ea013068bc3d5fc0d9de436a6f69d65f Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Fri, 26 Jul 2024 22:18:24 +0800 Subject: [PATCH] docs: add custom example for match text --- website/docs/monitor/custom-script.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/website/docs/monitor/custom-script.md b/website/docs/monitor/custom-script.md index 7819ec9..28d467a 100644 --- a/website/docs/monitor/custom-script.md +++ b/website/docs/monitor/custom-script.md @@ -54,6 +54,27 @@ return res.data.pull_count; replace `moonrailgun/tianji` to your own image name +### example for match text + +```js +const start = Date.now(); +const res = await request({ + url: "https://example.com/" +}); + +const usage = Date.now() - start; + +const matched = /maintain/.test(String(res.data)); + +if(matched) { + return -1; +} + +return usage; +``` + +return `-1` means somthing wrong. in this case, its means in html body include `maintain` text. + ### or more