mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2026-03-31 09:55:18 +08:00
路径规则、重写规则、URL跳转规则均支持匹配条件;URL跳转规则增加排序、是否启用功能
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"regexp"
|
||||
"strings"
|
||||
@@ -48,6 +49,7 @@ func (this *CreateAction) RunPost(params struct {
|
||||
IsBreak bool
|
||||
IsCaseInsensitive bool
|
||||
IsReverse bool
|
||||
CondsJSON []byte
|
||||
|
||||
Must *actions.Must
|
||||
}) {
|
||||
@@ -63,6 +65,20 @@ func (this *CreateAction) RunPost(params struct {
|
||||
}
|
||||
}
|
||||
|
||||
// 校验匹配条件
|
||||
if len(params.CondsJSON) > 0 {
|
||||
conds := &shared.HTTPRequestCondsConfig{}
|
||||
err := json.Unmarshal(params.CondsJSON, conds)
|
||||
if err != nil {
|
||||
this.Fail("匹配条件校验失败:" + err.Error())
|
||||
}
|
||||
|
||||
err = conds.Init()
|
||||
if err != nil {
|
||||
this.Fail("匹配条件校验失败:" + err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
// 自动加上前缀斜杠
|
||||
if params.PatternType == serverconfigs.HTTPLocationPatternTypePrefix ||
|
||||
params.PatternType == serverconfigs.HTTPLocationPatternTypeExact {
|
||||
@@ -79,6 +95,7 @@ func (this *CreateAction) RunPost(params struct {
|
||||
Description: params.Description,
|
||||
Pattern: resultPattern,
|
||||
IsBreak: params.IsBreak,
|
||||
CondsJSON: params.CondsJSON,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
|
||||
Reference in New Issue
Block a user