From f0b5f6ed7664c05cc83d3e2ebe2f5d684adb63c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Fri, 10 Nov 2023 16:36:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E2=80=9C=E8=B7=B3=E8=BD=ACURL=E2=80=9D?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/serverconfigs/http_page_config.go | 31 ++++++++++++++++++++--- pkg/serverconfigs/http_shutdown_config.go | 8 +++--- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/pkg/serverconfigs/http_page_config.go b/pkg/serverconfigs/http_page_config.go index 5b2bc0b..2d69216 100644 --- a/pkg/serverconfigs/http_page_config.go +++ b/pkg/serverconfigs/http_page_config.go @@ -2,6 +2,31 @@ package serverconfigs import "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" +type HTTPPageBodyType = string + +const ( + HTTPPageBodyTypeHTML HTTPPageBodyType = "html" + HTTPPageBodyTypeURL HTTPPageBodyType = "url" + HTTPPageBodyTypeRedirectURL HTTPPageBodyType = "redirectURL" +) + +func FindAllHTTPPageBodyTypes() []*shared.Definition { + return []*shared.Definition{ + { + Name: "HTML", + Code: HTTPPageBodyTypeHTML, + }, + { + Name: "读取URL", + Code: HTTPPageBodyTypeURL, + }, + { + Name: "跳转URL", + Code: HTTPPageBodyTypeRedirectURL, + }, + } +} + // HTTPPageConfig 特殊页面配置 // TODO 需要支持Header定义 type HTTPPageConfig struct { @@ -10,9 +35,9 @@ type HTTPPageConfig struct { Status []string `yaml:"status" json:"status"` // 响应支持40x, 50x, 3x2 NewStatus int `yaml:"newStatus" json:"newStatus"` // 新状态码 - BodyType shared.BodyType `yaml:"bodyType" json:"bodyType"` // 内容类型 - URL string `yaml:"url" json:"url"` // URL - Body string `yaml:"body" json:"body"` // 输出的内容 + BodyType HTTPPageBodyType `yaml:"bodyType" json:"bodyType"` // 内容类型 + URL string `yaml:"url" json:"url"` // URL + Body string `yaml:"body" json:"body"` // 输出的内容 statusList []*WildcardStatus hasStatusList bool diff --git a/pkg/serverconfigs/http_shutdown_config.go b/pkg/serverconfigs/http_shutdown_config.go index 7361f01..644ec0f 100644 --- a/pkg/serverconfigs/http_shutdown_config.go +++ b/pkg/serverconfigs/http_shutdown_config.go @@ -1,15 +1,13 @@ package serverconfigs -import "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" - // HTTPShutdownConfig 关闭页面配置 type HTTPShutdownConfig struct { IsPrior bool `yaml:"isPrior" json:"isPrior"` IsOn bool `yaml:"isOn" json:"isOn"` - BodyType shared.BodyType `yaml:"bodyType" json:"bodyType"` // 内容类型 - URL string `yaml:"url" json:"url"` // URL - Body string `yaml:"body" json:"body"` // 输出的内容 + BodyType HTTPPageBodyType `yaml:"bodyType" json:"bodyType"` // 内容类型 + URL string `yaml:"url" json:"url"` // URL + Body string `yaml:"body" json:"body"` // 输出的内容 Status int `yaml:"status" json:"status"`