Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions agent/app/api/v2/website.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ func (b *BaseApi) GetProxyConfig(c *gin.Context) {
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/proxies/update [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"修改网站 [domain] 反向代理配置 ","formatEN":"Update domain [domain] proxy config"}
// @x-panel-log {"bodyKeys":["id","name","operate"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"修改 [operate] 网站 [domain] 反向代理配置 [name] ","formatEN":"Update [operate] domain [domain] proxy config [name]"}
func (b *BaseApi) UpdateProxyConfig(c *gin.Context) {
var req request.WebsiteProxyConfig
if err := helper.CheckBindAndValidate(&req, c); err != nil {
Expand Down Expand Up @@ -550,7 +550,7 @@ func (b *BaseApi) DeleteProxyConfig(c *gin.Context) {
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/proxies/status [post]
// @x-panel-log {"bodyKeys":["id","name","status"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"更新网站 [domain] 反向代理配置 [name] 状态 [status] ","formatEN":"Update domain [domain] proxy config [name] status [status]"}
// @x-panel-log {"bodyKeys":["id","name","status"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"修改网站 [domain] 反向代理配置 [name] 状态 [status] ","formatEN":"Update domain [domain] proxy config [name] status [status]"}
func (b *BaseApi) UpdateProxyConfigStatus(c *gin.Context) {
var req request.WebsiteProxyStatusUpdate
if err := helper.CheckBindAndValidate(&req, c); err != nil {
Expand All @@ -572,7 +572,7 @@ func (b *BaseApi) UpdateProxyConfigStatus(c *gin.Context) {
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/proxies/file [post]
// @x-panel-log {"bodyKeys":["websiteID"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteID","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"更新反向代理文件 [domain]","formatEN":"Nginx conf proxy file update [domain]"}
// @x-panel-log {"bodyKeys":["websiteID","name"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteID","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"修改网站 [domain] 反向代理配置文件 [name] ","formatEN":"Update domain [domain] proxy config file [name]"}
func (b *BaseApi) UpdateProxyConfigFile(c *gin.Context) {
var req request.NginxProxyUpdate
if err := helper.CheckBindAndValidate(&req, c); err != nil {
Expand Down
27 changes: 17 additions & 10 deletions agent/app/service/website_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,21 @@ import (
)

func (w WebsiteService) OperateProxy(req request.WebsiteProxyConfig) (err error) {
switch req.Operate {
case "delete":
return w.DeleteProxy(request.WebsiteProxyDel{
ID: req.ID,
Name: req.Name,
})
case "disable":
fallthrough
case "enable":
return w.UpdateProxyStatus(request.WebsiteProxyStatusUpdate{
ID: req.ID,
Name: req.Name,
Status: req.Operate,
})
}
var (
website model.Website
par *parser.Parser
Expand Down Expand Up @@ -81,16 +96,8 @@ func (w WebsiteService) OperateProxy(req request.WebsiteProxyConfig) (err error)
if err != nil {
return
}
case "delete":
_ = fileOp.DeleteFile(includePath)
_ = fileOp.DeleteFile(backPath)
return updateNginxConfig(constant.NginxScopeServer, nil, &website)
case "disable":
_ = fileOp.Rename(includePath, backPath)
return updateNginxConfig(constant.NginxScopeServer, nil, &website)
case "enable":
_ = fileOp.Rename(backPath, includePath)
return updateNginxConfig(constant.NginxScopeServer, nil, &website)
default:
return errors.New("unknown operate")
}

config.FilePath = includePath
Expand Down
17 changes: 10 additions & 7 deletions core/cmd/server/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -20609,10 +20609,11 @@ const docTemplate = `{
}
],
"bodyKeys": [
"websiteID"
"websiteID",
"name"
],
"formatEN": "Nginx conf proxy file update [domain]",
"formatZH": "更新反向代理文件 [domain]",
"formatEN": "Update domain [domain] proxy config file [name]",
"formatZH": "修改网站 [domain] 反向代理配置文件 [name] ",
"paramKeys": []
}
}
Expand Down Expand Up @@ -20667,7 +20668,7 @@ const docTemplate = `{
"status"
],
"formatEN": "Update domain [domain] proxy config [name] status [status]",
"formatZH": "更新网站 [domain] 反向代理配置 [name] 状态 [status] ",
"formatZH": "修改网站 [domain] 反向代理配置 [name] 状态 [status] ",
"paramKeys": []
}
}
Expand Down Expand Up @@ -20717,10 +20718,12 @@ const docTemplate = `{
}
],
"bodyKeys": [
"id"
"id",
"name",
"operate"
],
"formatEN": "Update domain [domain] proxy config",
"formatZH": "修改网站 [domain] 反向代理配置 ",
"formatEN": "Update [operate] domain [domain] proxy config [name]",
"formatZH": "修改 [operate] 网站 [domain] 反向代理配置 [name] ",
"paramKeys": []
}
}
Expand Down
17 changes: 10 additions & 7 deletions core/cmd/server/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -20605,10 +20605,11 @@
}
],
"bodyKeys": [
"websiteID"
"websiteID",
"name"
],
"formatEN": "Nginx conf proxy file update [domain]",
"formatZH": "更新反向代理文件 [domain]",
"formatEN": "Update domain [domain] proxy config file [name]",
"formatZH": "修改网站 [domain] 反向代理配置文件 [name] ",
"paramKeys": []
}
}
Expand Down Expand Up @@ -20663,7 +20664,7 @@
"status"
],
"formatEN": "Update domain [domain] proxy config [name] status [status]",
"formatZH": "更新网站 [domain] 反向代理配置 [name] 状态 [status] ",
"formatZH": "修改网站 [domain] 反向代理配置 [name] 状态 [status] ",
"paramKeys": []
}
}
Expand Down Expand Up @@ -20713,10 +20714,12 @@
}
],
"bodyKeys": [
"id"
"id",
"name",
"operate"
],
"formatEN": "Update domain [domain] proxy config",
"formatZH": "修改网站 [domain] 反向代理配置 ",
"formatEN": "Update [operate] domain [domain] proxy config [name]",
"formatZH": "修改 [operate] 网站 [domain] 反向代理配置 [name] ",
"paramKeys": []
}
}
Expand Down
17 changes: 10 additions & 7 deletions core/cmd/server/docs/x-log.json
Original file line number Diff line number Diff line change
Expand Up @@ -3029,7 +3029,8 @@
},
"/websites/proxies/file": {
"bodyKeys": [
"websiteID"
"websiteID",
"name"
],
"paramKeys": [],
"beforeFunctions": [
Expand All @@ -3042,8 +3043,8 @@
"output_value": "domain"
}
],
"formatZH": "更新反向代理文件 [domain]",
"formatEN": "Nginx conf proxy file update [domain]"
"formatZH": "修改网站 [domain] 反向代理配置文件 [name] ",
"formatEN": "Update domain [domain] proxy config file [name]"
},
"/websites/proxies/status": {
"bodyKeys": [
Expand All @@ -3062,12 +3063,14 @@
"output_value": "domain"
}
],
"formatZH": "更新网站 [domain] 反向代理配置 [name] 状态 [status] ",
"formatZH": "修改网站 [domain] 反向代理配置 [name] 状态 [status] ",
"formatEN": "Update domain [domain] proxy config [name] status [status]"
},
"/websites/proxies/update": {
"bodyKeys": [
"id"
"id",
"name",
"operate"
],
"paramKeys": [],
"beforeFunctions": [
Expand All @@ -3080,8 +3083,8 @@
"output_value": "domain"
}
],
"formatZH": "修改网站 [domain] 反向代理配置 ",
"formatEN": "Update domain [domain] proxy config"
"formatZH": "修改 [operate] 网站 [domain] 反向代理配置 [name] ",
"formatEN": "Update [operate] domain [domain] proxy config [name]"
},
"/websites/proxy/clear": {
"bodyKeys": [],
Expand Down
Loading