mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2026-04-04 13:25:18 +08:00
阶段性提交
This commit is contained in:
54
pkg/serverconfigs/shared/http_headers_config.go
Normal file
54
pkg/serverconfigs/shared/http_headers_config.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package shared
|
||||
|
||||
// HeaderList定义
|
||||
type HTTPHeadersConfig struct {
|
||||
AddHeaders []*HTTPHeaderConfig `yaml:"addHeaders" json:"addHeaders"` // TODO
|
||||
AddTrailers []*HTTPHeaderConfig `yaml:"addTrailers" json:"addTrailers"` // TODO
|
||||
SetHeaders []*HTTPHeaderConfig `yaml:"setHeaders" json:"setHeaders"` // TODO
|
||||
ReplaceHeaders []*HTTPHeaderConfig `yaml:"replaceHeaders" json:"replaceHeaders"` // TODO
|
||||
|
||||
Expires *HTTPExpireHeaderConfig `yaml:"expires" json:"expires"` // TODO
|
||||
}
|
||||
|
||||
// 获取新对象
|
||||
func NewHTTPHeaders() *HTTPHeadersConfig {
|
||||
return &HTTPHeadersConfig{}
|
||||
}
|
||||
|
||||
// 校验
|
||||
func (this *HTTPHeadersConfig) Init() error {
|
||||
for _, h := range this.AddHeaders {
|
||||
err := h.Init()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
for _, h := range this.AddTrailers {
|
||||
err := h.Init()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
for _, h := range this.SetHeaders {
|
||||
err := h.Init()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
for _, h := range this.ReplaceHeaders {
|
||||
err := h.Init()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// 判断是否为空
|
||||
func (this *HTTPHeadersConfig) IsEmpty() bool {
|
||||
return len(this.AddHeaders) == 0 && len(this.AddTrailers) == 0 && len(this.SetHeaders) == 0 && len(this.ReplaceHeaders) == 0 && this.Expires == nil
|
||||
}
|
||||
Reference in New Issue
Block a user