mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2026-02-08 17:35:36 +08:00
实现路径规则部分功能
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user