集群可以设置默认的WAF策略、缓存策略

This commit is contained in:
GoEdgeLab
2020-12-17 15:50:44 +08:00
parent ee549b945d
commit 41ac159e23
100 changed files with 1172 additions and 488 deletions

View File

@@ -3,11 +3,8 @@ package cache
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/models"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/maps"
)
type CreatePopupAction struct {
@@ -19,45 +16,16 @@ func (this *CreatePopupAction) Init() {
}
func (this *CreatePopupAction) RunGet(params struct{}) {
// 缓存策略列表
cachePoliciesResp, err := this.RPC().HTTPCachePolicyRPC().FindAllEnabledHTTPCachePolicies(this.AdminContext(), &pb.FindAllEnabledHTTPCachePoliciesRequest{})
if err != nil {
this.ErrorPage(err)
return
}
cachePolicyMaps := []maps.Map{}
for _, cachePolicy := range cachePoliciesResp.CachePolicies {
cachePolicyMaps = append(cachePolicyMaps, maps.Map{
"id": cachePolicy.Id,
"name": cachePolicy.Name,
})
}
this.Data["cachePolicies"] = cachePolicyMaps
this.Show()
}
func (this *CreatePopupAction) RunPost(params struct {
CachePolicyId int64
CacheRefJSON []byte
CacheRefJSON []byte
Must *actions.Must
}) {
if params.CachePolicyId <= 0 {
this.Fail("请选择要使用的缓存策略")
}
cachePolicy, err := models.SharedHTTPCachePolicyDAO.FindEnabledCachePolicyConfig(this.AdminContext(), params.CachePolicyId)
if err != nil {
this.ErrorPage(err)
return
}
if cachePolicy == nil {
this.Fail("找不到你要使用的缓存策略")
}
cacheRef := &serverconfigs.HTTPCacheRef{}
err = json.Unmarshal(params.CacheRefJSON, cacheRef)
err := json.Unmarshal(params.CacheRefJSON, cacheRef)
if err != nil {
this.ErrorPage(err)
return
@@ -66,9 +34,6 @@ func (this *CreatePopupAction) RunPost(params struct {
this.Fail("请输入缓存Key")
}
cacheRef.CachePolicyId = cachePolicy.Id
cacheRef.CachePolicy = cachePolicy
err = cacheRef.Init()
if err != nil {
this.ErrorPage(err)