mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-09-22 08:00:53 +00:00
chore: optimize website proxy api and log (#12052)
This commit is contained in:
@@ -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 {
|
||||
@@ -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 {
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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": []
|
||||
}
|
||||
}
|
||||
@@ -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": []
|
||||
}
|
||||
}
|
||||
@@ -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": []
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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": []
|
||||
}
|
||||
}
|
||||
@@ -20663,7 +20664,7 @@
|
||||
"status"
|
||||
],
|
||||
"formatEN": "Update domain [domain] proxy config [name] status [status]",
|
||||
"formatZH": "更新网站 [domain] 反向代理配置 [name] 状态 [status] ",
|
||||
"formatZH": "修改网站 [domain] 反向代理配置 [name] 状态 [status] ",
|
||||
"paramKeys": []
|
||||
}
|
||||
}
|
||||
@@ -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": []
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3029,7 +3029,8 @@
|
||||
},
|
||||
"/websites/proxies/file": {
|
||||
"bodyKeys": [
|
||||
"websiteID"
|
||||
"websiteID",
|
||||
"name"
|
||||
],
|
||||
"paramKeys": [],
|
||||
"beforeFunctions": [
|
||||
@@ -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": [
|
||||
@@ -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": [
|
||||
@@ -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": [],
|
||||
|
||||
Reference in New Issue
Block a user