实现访问日志配置

This commit is contained in:
刘祥超
2020-09-20 11:56:30 +08:00
parent c1327e8ca8
commit c6b18602ae
9 changed files with 241 additions and 2 deletions

View File

@@ -136,6 +136,16 @@ func (this *HTTPWebDAO) ComposeWebConfig(webId int64) (*serverconfigs.HTTPWebCon
}
}
// 访问日志
if IsNotNull(web.AccessLog) {
accessLogConfig := &serverconfigs.HTTPAccessLogConfig{}
err = json.Unmarshal([]byte(web.AccessLog), accessLogConfig)
if err != nil {
return nil, err
}
config.AccessLog = accessLogConfig
}
// TODO 更多配置
return config, nil
@@ -265,6 +275,22 @@ func (this *HTTPWebDAO) UpdateWebShutdown(webId int64, shutdownJSON []byte) erro
return this.NotifyUpdating(webId)
}
// 更改访问日志策略
func (this *HTTPWebDAO) UpdateWebAccessLogConfig(webId int64, accessLogJSON []byte) error {
if webId <= 0 {
return errors.New("invalid webId")
}
op := NewHTTPWebOperator()
op.Id = webId
op.AccessLog = JSONBytes(accessLogJSON)
_, err := this.Save(op)
if err != nil {
return err
}
return this.NotifyUpdating(webId)
}
// 通知更新
func (this *HTTPWebDAO) NotifyUpdating(webId int64) error {
err := SharedServerDAO.UpdateServerIsUpdatingWithWebId(webId)