From c3600b66bfd8be94bb5f4c3a5f9763e060ede098 Mon Sep 17 00:00:00 2001 From: qydysky Date: Thu, 31 Oct 2024 01:52:06 +0800 Subject: [PATCH] 1 --- README.md | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ main/main.go | 4 ---- 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4be6955..2b50a4c 100755 --- a/README.md +++ b/README.md @@ -15,6 +15,59 @@ 支持嵌入到其他项目中/独立运行 +示例 +```json +[ + { + "addr": "127.0.0.1:10000", + "routes": [ + { + "path": ["/"], + "pathAdd": true, + "filiter": { + "reqUri": { + "accessRule": "!{stop}", + "items": { + "stop": "(main\\.json)" + } + } + }, + "backs": [ + { + "name": "back1", + "to": "./", + "weight": "1" + } + ] + } + ] + } +] +``` +``` +curl http://127.0.0.1:10000/ + + +
+front.run
+main.json
+main.log
+
+ +curl http://127.0.0.1:10000/main.json -I +HTTP/1.1 403 Forbidden +X-Front-Error: ErrPatherCheckFail +Date: Wed, 30 Oct 2024 17:50:22 GMT + +curl http://127.0.0.1:10000/main.log -I +HTTP/1.1 200 OK +Accept-Ranges: bytes +Content-Length: 1700014 +Content-Type: text/x-log; charset=utf-8 +Last-Modified: Wed, 30 Oct 2024 17:51:23 GMT +Date: Wed, 30 Oct 2024 17:51:23 GMT +``` + 配置为json数组格式[],下面为数组中的其中一个{},下述字段*倾斜*的,表示不会根据配置动态加载 config: diff --git a/main/main.go b/main/main.go index 3029c46..597e1e7 100755 --- a/main/main.go +++ b/main/main.go @@ -24,7 +24,6 @@ func main() { // 获取config路径 configP := flag.String("c", "main.json", "config") logfile := flag.String("log", "main.log", "logfile") - testP := flag.Int("t", 0, "test port") _ = flag.Bool("q", false, "no log") _ = flag.Bool("dq", false, "no debug log") flag.Parse() @@ -72,9 +71,6 @@ func main() { return } - // 测试响应 - go pfront.Test(ctx, *testP, logger.Base("测试")) - for i := 0; i < len(configS); i++ { go configS[i].Run(ctx, logger) } -- 2.39.2