优化API命名

This commit is contained in:
GoEdgeLab
2021-11-24 12:00:38 +08:00
parent 36ea672d37
commit 119e9ea510
7 changed files with 120 additions and 77 deletions

View File

@@ -419,6 +419,9 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
config.RemoteAddr = remoteAddrConfig
}
// mergeSlashes
config.MergeSlashes = web.MergeSlashes == 1
if cacheMap != nil {
cacheMap.Put(cacheKey, config)
}
@@ -1037,6 +1040,8 @@ func (this *HTTPWebDAO) UpdateWebHostRedirects(tx *dbs.Tx, webId int64, hostRedi
return this.NotifyUpdate(tx, webId)
}
// 通用设置
// FindWebHostRedirects 查找主机跳转
func (this *HTTPWebDAO) FindWebHostRedirects(tx *dbs.Tx, webId int64) ([]byte, error) {
col, err := this.Query(tx).
@@ -1049,6 +1054,17 @@ func (this *HTTPWebDAO) FindWebHostRedirects(tx *dbs.Tx, webId int64) ([]byte, e
return []byte(col), nil
}
// UpdateWebCommon 修改通用设置
func (this *HTTPWebDAO) UpdateWebCommon(tx *dbs.Tx, webId int64, mergeSlashes bool) error {
if webId <= 0 {
return errors.New("invalid webId")
}
var op = NewHTTPWebOperator()
op.Id = webId
op.MergeSlashes = mergeSlashes
return this.Save(tx, op)
}
// NotifyUpdate 通知更新
func (this *HTTPWebDAO) NotifyUpdate(tx *dbs.Tx, webId int64) error {
// server

View File

@@ -32,6 +32,7 @@ type HTTPWeb struct {
Auth string `field:"auth"` // 认证策略配置
Webp string `field:"webp"` // WebP配置
RemoteAddr string `field:"remoteAddr"` // 客户端IP配置
MergeSlashes uint8 `field:"mergeSlashes"` // 是否合并路径中的斜杠
}
type HTTPWebOperator struct {
@@ -65,6 +66,7 @@ type HTTPWebOperator struct {
Auth interface{} // 认证策略配置
Webp interface{} // WebP配置
RemoteAddr interface{} // 客户端IP配置
MergeSlashes interface{} // 是否合并路径中的斜杠
}
func NewHTTPWebOperator() *HTTPWebOperator {