实现路径规则部分功能

This commit is contained in:
GoEdgeLab
2020-09-21 19:51:56 +08:00
parent 62b9efe0e6
commit 8a1cfa92ca
17 changed files with 415 additions and 23 deletions

View File

@@ -184,6 +184,24 @@ func (this *HTTPWebDAO) ComposeWebConfig(webId int64) (*serverconfigs.HTTPWebCon
config.FirewallRef = firewallRef
}
// 路径规则
if IsNotNull(web.Locations) {
refs := []*serverconfigs.HTTPLocationRef{}
err = json.Unmarshal([]byte(web.Locations), &refs)
if err != nil {
return nil, err
}
if len(refs) > 0 {
config.LocationRefs = refs
locations, err := SharedHTTPLocationDAO.ConvertLocationRefs(refs)
if err != nil {
return nil, err
}
config.Locations = locations
}
}
// TODO 更多配置
return config, nil
@@ -377,6 +395,22 @@ func (this *HTTPWebDAO) UpdateWebFirewall(webId int64, firewallJSON []byte) erro
return this.NotifyUpdating(webId)
}
// 更改路径规则配置
func (this *HTTPWebDAO) UpdateWebLocations(webId int64, locationsJSON []byte) error {
if webId <= 0 {
return errors.New("invalid webId")
}
op := NewHTTPWebOperator()
op.Id = webId
op.Locations = JSONBytes(locationsJSON)
_, err := this.Save(op)
if err != nil {
return err
}
return this.NotifyUpdating(webId)
}
// 通知更新
func (this *HTTPWebDAO) NotifyUpdating(webId int64) error {
err := SharedServerDAO.UpdateServerIsUpdatingWithWebId(webId)