Files
EdgeCommon/pkg/serverconfigs/http_access_log_storage_policy.go

43 lines
1.2 KiB
Go
Raw Normal View History

2020-09-20 11:56:22 +08:00
package serverconfigs
import (
2020-09-26 08:07:24 +08:00
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
2020-09-20 11:56:22 +08:00
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
2021-01-01 20:48:30 +08:00
"github.com/iwind/TeaGo/maps"
2020-09-20 11:56:22 +08:00
)
// 日志存储策略
type HTTPAccessLogStoragePolicy struct {
2020-09-29 17:23:11 +08:00
Id int64 `yaml:"id" json:"id"`
Name string `yaml:"name" json:"name"`
IsOn bool `yaml:"isOn" json:"isOn"`
Type string `yaml:"type" json:"type"` // 存储类型
2021-01-01 20:48:30 +08:00
Options maps.Map `yaml:"options" json:"options"` // 存储选项
2020-09-29 17:23:11 +08:00
Conds *shared.HTTPRequestCondsConfig `yaml:"conds" json:"conds"` // 请求条件
2020-09-20 11:56:22 +08:00
}
// 校验
func (this *HTTPAccessLogStoragePolicy) Init() error {
// cond
2020-09-29 17:23:11 +08:00
if this.Conds != nil {
err := this.Conds.Init()
if err != nil {
return err
2020-09-20 11:56:22 +08:00
}
}
return nil
}
// 匹配关键词
func (this *HTTPAccessLogStoragePolicy) MatchKeyword(keyword string) (matched bool, name string, tags []string) {
if configutils.MatchKeyword(this.Name, keyword) || configutils.MatchKeyword(this.Type, keyword) {
matched = true
name = this.Name
if len(this.Type) > 0 {
tags = []string{"类型:" + this.Type}
}
}
return
}