mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 11:27:17 +08:00
feat: 移除部分软件服务接口
This commit is contained in:
@@ -126,7 +126,7 @@ func (r *CertController) Algorithms(ctx http.Context) http.Response {
|
||||
// @Router /panel/cert/users [get]
|
||||
func (r *CertController) UserList(ctx http.Context) http.Response {
|
||||
var paginateRequest commonrequests.Paginate
|
||||
sanitize := Sanitize(ctx, &paginateRequest)
|
||||
sanitize := SanitizeRequest(ctx, &paginateRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -160,7 +160,7 @@ func (r *CertController) UserList(ctx http.Context) http.Response {
|
||||
// @Router /panel/cert/users [post]
|
||||
func (r *CertController) UserStore(ctx http.Context) http.Response {
|
||||
var storeRequest requests.UserStore
|
||||
sanitize := Sanitize(ctx, &storeRequest)
|
||||
sanitize := SanitizeRequest(ctx, &storeRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -190,7 +190,7 @@ func (r *CertController) UserStore(ctx http.Context) http.Response {
|
||||
// @Router /panel/cert/users/{id} [put]
|
||||
func (r *CertController) UserUpdate(ctx http.Context) http.Response {
|
||||
var updateRequest requests.UserUpdate
|
||||
sanitize := Sanitize(ctx, &updateRequest)
|
||||
sanitize := SanitizeRequest(ctx, &updateRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -219,7 +219,7 @@ func (r *CertController) UserUpdate(ctx http.Context) http.Response {
|
||||
// @Router /panel/cert/users/{id} [get]
|
||||
func (r *CertController) UserShow(ctx http.Context) http.Response {
|
||||
var showAndDestroyRequest requests.UserShowAndDestroy
|
||||
sanitize := Sanitize(ctx, &showAndDestroyRequest)
|
||||
sanitize := SanitizeRequest(ctx, &showAndDestroyRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -249,7 +249,7 @@ func (r *CertController) UserShow(ctx http.Context) http.Response {
|
||||
// @Router /panel/cert/users/{id} [delete]
|
||||
func (r *CertController) UserDestroy(ctx http.Context) http.Response {
|
||||
var showAndDestroyRequest requests.UserShowAndDestroy
|
||||
sanitize := Sanitize(ctx, &showAndDestroyRequest)
|
||||
sanitize := SanitizeRequest(ctx, &showAndDestroyRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -278,7 +278,7 @@ func (r *CertController) UserDestroy(ctx http.Context) http.Response {
|
||||
// @Router /panel/cert/dns [get]
|
||||
func (r *CertController) DNSList(ctx http.Context) http.Response {
|
||||
var paginateRequest commonrequests.Paginate
|
||||
sanitize := Sanitize(ctx, &paginateRequest)
|
||||
sanitize := SanitizeRequest(ctx, &paginateRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -312,7 +312,7 @@ func (r *CertController) DNSList(ctx http.Context) http.Response {
|
||||
// @Router /panel/cert/dns [post]
|
||||
func (r *CertController) DNSStore(ctx http.Context) http.Response {
|
||||
var storeRequest requests.DNSStore
|
||||
sanitize := Sanitize(ctx, &storeRequest)
|
||||
sanitize := SanitizeRequest(ctx, &storeRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -340,7 +340,7 @@ func (r *CertController) DNSStore(ctx http.Context) http.Response {
|
||||
// @Router /panel/cert/dns/{id} [get]
|
||||
func (r *CertController) DNSShow(ctx http.Context) http.Response {
|
||||
var showAndDestroyRequest requests.DNSShowAndDestroy
|
||||
sanitize := Sanitize(ctx, &showAndDestroyRequest)
|
||||
sanitize := SanitizeRequest(ctx, &showAndDestroyRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -371,7 +371,7 @@ func (r *CertController) DNSShow(ctx http.Context) http.Response {
|
||||
// @Router /panel/cert/dns/{id} [put]
|
||||
func (r *CertController) DNSUpdate(ctx http.Context) http.Response {
|
||||
var updateRequest requests.DNSUpdate
|
||||
sanitize := Sanitize(ctx, &updateRequest)
|
||||
sanitize := SanitizeRequest(ctx, &updateRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -401,7 +401,7 @@ func (r *CertController) DNSUpdate(ctx http.Context) http.Response {
|
||||
// @Router /panel/cert/dns/{id} [delete]
|
||||
func (r *CertController) DNSDestroy(ctx http.Context) http.Response {
|
||||
var showAndDestroyRequest requests.DNSShowAndDestroy
|
||||
sanitize := Sanitize(ctx, &showAndDestroyRequest)
|
||||
sanitize := SanitizeRequest(ctx, &showAndDestroyRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -430,7 +430,7 @@ func (r *CertController) DNSDestroy(ctx http.Context) http.Response {
|
||||
// @Router /panel/cert/certs [get]
|
||||
func (r *CertController) CertList(ctx http.Context) http.Response {
|
||||
var paginateRequest commonrequests.Paginate
|
||||
sanitize := Sanitize(ctx, &paginateRequest)
|
||||
sanitize := SanitizeRequest(ctx, &paginateRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -464,7 +464,7 @@ func (r *CertController) CertList(ctx http.Context) http.Response {
|
||||
// @Router /panel/cert/certs [post]
|
||||
func (r *CertController) CertStore(ctx http.Context) http.Response {
|
||||
var storeRequest requests.CertStore
|
||||
sanitize := Sanitize(ctx, &storeRequest)
|
||||
sanitize := SanitizeRequest(ctx, &storeRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -494,7 +494,7 @@ func (r *CertController) CertStore(ctx http.Context) http.Response {
|
||||
// @Router /panel/cert/certs/{id} [put]
|
||||
func (r *CertController) CertUpdate(ctx http.Context) http.Response {
|
||||
var updateRequest requests.CertUpdate
|
||||
sanitize := Sanitize(ctx, &updateRequest)
|
||||
sanitize := SanitizeRequest(ctx, &updateRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -523,7 +523,7 @@ func (r *CertController) CertUpdate(ctx http.Context) http.Response {
|
||||
// @Router /panel/cert/certs/{id} [get]
|
||||
func (r *CertController) CertShow(ctx http.Context) http.Response {
|
||||
var showAndDestroyRequest requests.CertShowAndDestroy
|
||||
sanitize := Sanitize(ctx, &showAndDestroyRequest)
|
||||
sanitize := SanitizeRequest(ctx, &showAndDestroyRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -553,7 +553,7 @@ func (r *CertController) CertShow(ctx http.Context) http.Response {
|
||||
// @Router /panel/cert/certs/{id} [delete]
|
||||
func (r *CertController) CertDestroy(ctx http.Context) http.Response {
|
||||
var showAndDestroyRequest requests.CertShowAndDestroy
|
||||
sanitize := Sanitize(ctx, &showAndDestroyRequest)
|
||||
sanitize := SanitizeRequest(ctx, &showAndDestroyRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -583,7 +583,7 @@ func (r *CertController) CertDestroy(ctx http.Context) http.Response {
|
||||
// @Router /panel/cert/obtain [post]
|
||||
func (r *CertController) Obtain(ctx http.Context) http.Response {
|
||||
var obtainRequest requests.Obtain
|
||||
sanitize := Sanitize(ctx, &obtainRequest)
|
||||
sanitize := SanitizeRequest(ctx, &obtainRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -625,7 +625,7 @@ func (r *CertController) Obtain(ctx http.Context) http.Response {
|
||||
// @Router /panel/cert/renew [post]
|
||||
func (r *CertController) Renew(ctx http.Context) http.Response {
|
||||
var renewRequest requests.Renew
|
||||
sanitize := Sanitize(ctx, &renewRequest)
|
||||
sanitize := SanitizeRequest(ctx, &renewRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -654,7 +654,7 @@ func (r *CertController) Renew(ctx http.Context) http.Response {
|
||||
// @Router /panel/cert/manualDNS [post]
|
||||
func (r *CertController) ManualDNS(ctx http.Context) http.Response {
|
||||
var obtainRequest requests.Obtain
|
||||
sanitize := Sanitize(ctx, &obtainRequest)
|
||||
sanitize := SanitizeRequest(ctx, &obtainRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -683,7 +683,7 @@ func (r *CertController) ManualDNS(ctx http.Context) http.Response {
|
||||
// @Router /panel/cert/deploy [post]
|
||||
func (r *CertController) Deploy(ctx http.Context) http.Response {
|
||||
var deployRequest requests.CertDeploy
|
||||
sanitize := Sanitize(ctx, &deployRequest)
|
||||
sanitize := SanitizeRequest(ctx, &deployRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ func NewContainerController() *ContainerController {
|
||||
// @Router /panel/container/list [get]
|
||||
func (r *ContainerController) ContainerList(ctx http.Context) http.Response {
|
||||
var request commonrequests.Paginate
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ func (r *ContainerController) ContainerSearch(ctx http.Context) http.Response {
|
||||
// @Router /panel/container/create [post]
|
||||
func (r *ContainerController) ContainerCreate(ctx http.Context) http.Response {
|
||||
var request requests.ContainerCreate
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ func (r *ContainerController) ContainerCreate(ctx http.Context) http.Response {
|
||||
// @Router /panel/container/remove [post]
|
||||
func (r *ContainerController) ContainerRemove(ctx http.Context) http.Response {
|
||||
var request requests.ID
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ func (r *ContainerController) ContainerRemove(ctx http.Context) http.Response {
|
||||
// @Router /panel/container/start [post]
|
||||
func (r *ContainerController) ContainerStart(ctx http.Context) http.Response {
|
||||
var request requests.ID
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -266,7 +266,7 @@ func (r *ContainerController) ContainerStart(ctx http.Context) http.Response {
|
||||
// @Router /panel/container/stop [post]
|
||||
func (r *ContainerController) ContainerStop(ctx http.Context) http.Response {
|
||||
var request requests.ID
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ func (r *ContainerController) ContainerStop(ctx http.Context) http.Response {
|
||||
// @Router /panel/container/restart [post]
|
||||
func (r *ContainerController) ContainerRestart(ctx http.Context) http.Response {
|
||||
var request requests.ID
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -311,7 +311,7 @@ func (r *ContainerController) ContainerRestart(ctx http.Context) http.Response {
|
||||
// @Success 200 {object} SuccessResponse
|
||||
func (r *ContainerController) ContainerPause(ctx http.Context) http.Response {
|
||||
var request requests.ID
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -335,7 +335,7 @@ func (r *ContainerController) ContainerPause(ctx http.Context) http.Response {
|
||||
// @Router /panel/container/unpause [post]
|
||||
func (r *ContainerController) ContainerUnpause(ctx http.Context) http.Response {
|
||||
var request requests.ID
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -358,7 +358,7 @@ func (r *ContainerController) ContainerUnpause(ctx http.Context) http.Response {
|
||||
// @Router /panel/container/inspect [get]
|
||||
func (r *ContainerController) ContainerInspect(ctx http.Context) http.Response {
|
||||
var request requests.ID
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -382,7 +382,7 @@ func (r *ContainerController) ContainerInspect(ctx http.Context) http.Response {
|
||||
// @Router /panel/container/kill [post]
|
||||
func (r *ContainerController) ContainerKill(ctx http.Context) http.Response {
|
||||
var request requests.ID
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -405,7 +405,7 @@ func (r *ContainerController) ContainerKill(ctx http.Context) http.Response {
|
||||
// @Router /panel/container/rename [post]
|
||||
func (r *ContainerController) ContainerRename(ctx http.Context) http.Response {
|
||||
var request requests.ContainerRename
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -428,7 +428,7 @@ func (r *ContainerController) ContainerRename(ctx http.Context) http.Response {
|
||||
// @Router /panel/container/stats [get]
|
||||
func (r *ContainerController) ContainerStats(ctx http.Context) http.Response {
|
||||
var request requests.ID
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -452,7 +452,7 @@ func (r *ContainerController) ContainerStats(ctx http.Context) http.Response {
|
||||
// @Router /panel/container/exist [get]
|
||||
func (r *ContainerController) ContainerExist(ctx http.Context) http.Response {
|
||||
var request requests.ID
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -476,7 +476,7 @@ func (r *ContainerController) ContainerExist(ctx http.Context) http.Response {
|
||||
// @Router /panel/container/logs [get]
|
||||
func (r *ContainerController) ContainerLogs(ctx http.Context) http.Response {
|
||||
var request requests.ID
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -517,7 +517,7 @@ func (r *ContainerController) ContainerPrune(ctx http.Context) http.Response {
|
||||
// @Router /panel/container/network/list [get]
|
||||
func (r *ContainerController) NetworkList(ctx http.Context) http.Response {
|
||||
var request commonrequests.Paginate
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -592,7 +592,7 @@ func (r *ContainerController) NetworkList(ctx http.Context) http.Response {
|
||||
// @Router /panel/container/network/create [post]
|
||||
func (r *ContainerController) NetworkCreate(ctx http.Context) http.Response {
|
||||
var request requests.NetworkCreate
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -616,7 +616,7 @@ func (r *ContainerController) NetworkCreate(ctx http.Context) http.Response {
|
||||
// @Router /panel/container/network/remove [post]
|
||||
func (r *ContainerController) NetworkRemove(ctx http.Context) http.Response {
|
||||
var request requests.ID
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -639,7 +639,7 @@ func (r *ContainerController) NetworkRemove(ctx http.Context) http.Response {
|
||||
// @Router /panel/container/network/exist [get]
|
||||
func (r *ContainerController) NetworkExist(ctx http.Context) http.Response {
|
||||
var request requests.ID
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -663,7 +663,7 @@ func (r *ContainerController) NetworkExist(ctx http.Context) http.Response {
|
||||
// @Router /panel/container/network/inspect [get]
|
||||
func (r *ContainerController) NetworkInspect(ctx http.Context) http.Response {
|
||||
var request requests.ID
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -688,7 +688,7 @@ func (r *ContainerController) NetworkInspect(ctx http.Context) http.Response {
|
||||
// @Router /panel/container/network/connect [post]
|
||||
func (r *ContainerController) NetworkConnect(ctx http.Context) http.Response {
|
||||
var request requests.NetworkConnectDisConnect
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -712,7 +712,7 @@ func (r *ContainerController) NetworkConnect(ctx http.Context) http.Response {
|
||||
// @Router /panel/container/network/disconnect [post]
|
||||
func (r *ContainerController) NetworkDisconnect(ctx http.Context) http.Response {
|
||||
var request requests.NetworkConnectDisConnect
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -752,7 +752,7 @@ func (r *ContainerController) NetworkPrune(ctx http.Context) http.Response {
|
||||
// @Router /panel/container/image/list [get]
|
||||
func (r *ContainerController) ImageList(ctx http.Context) http.Response {
|
||||
var request commonrequests.Paginate
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -808,7 +808,7 @@ func (r *ContainerController) ImageList(ctx http.Context) http.Response {
|
||||
// @Router /panel/container/image/exist [get]
|
||||
func (r *ContainerController) ImageExist(ctx http.Context) http.Response {
|
||||
var request requests.ID
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -833,7 +833,7 @@ func (r *ContainerController) ImageExist(ctx http.Context) http.Response {
|
||||
// @Router /panel/container/image/pull [post]
|
||||
func (r *ContainerController) ImagePull(ctx http.Context) http.Response {
|
||||
var request requests.ImagePull
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -856,7 +856,7 @@ func (r *ContainerController) ImagePull(ctx http.Context) http.Response {
|
||||
// @Router /panel/container/image/remove [post]
|
||||
func (r *ContainerController) ImageRemove(ctx http.Context) http.Response {
|
||||
var request requests.ID
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -896,7 +896,7 @@ func (r *ContainerController) ImagePrune(ctx http.Context) http.Response {
|
||||
// @Router /panel/container/image/inspect [get]
|
||||
func (r *ContainerController) ImageInspect(ctx http.Context) http.Response {
|
||||
var request requests.ID
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -920,7 +920,7 @@ func (r *ContainerController) ImageInspect(ctx http.Context) http.Response {
|
||||
// @Router /panel/container/volume/list [get]
|
||||
func (r *ContainerController) VolumeList(ctx http.Context) http.Response {
|
||||
var request commonrequests.Paginate
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -986,7 +986,7 @@ func (r *ContainerController) VolumeList(ctx http.Context) http.Response {
|
||||
// @Router /panel/container/volume/create [post]
|
||||
func (r *ContainerController) VolumeCreate(ctx http.Context) http.Response {
|
||||
var request requests.VolumeCreate
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -1010,7 +1010,7 @@ func (r *ContainerController) VolumeCreate(ctx http.Context) http.Response {
|
||||
// @Router /panel/container/volume/exist [get]
|
||||
func (r *ContainerController) VolumeExist(ctx http.Context) http.Response {
|
||||
var request requests.ID
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -1034,7 +1034,7 @@ func (r *ContainerController) VolumeExist(ctx http.Context) http.Response {
|
||||
// @Router /panel/container/volume/inspect [get]
|
||||
func (r *ContainerController) VolumeInspect(ctx http.Context) http.Response {
|
||||
var request requests.ID
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -1058,7 +1058,7 @@ func (r *ContainerController) VolumeInspect(ctx http.Context) http.Response {
|
||||
// @Router /panel/container/volume/remove [post]
|
||||
func (r *ContainerController) VolumeRemove(ctx http.Context) http.Response {
|
||||
var request requests.ID
|
||||
if sanitize := Sanitize(ctx, &request); sanitize != nil {
|
||||
if sanitize := SanitizeRequest(ctx, &request); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ func ErrorSystem(ctx http.Context) http.Response {
|
||||
})
|
||||
}
|
||||
|
||||
// Sanitize 消毒请求参数
|
||||
func Sanitize(ctx http.Context, request http.FormRequest) http.Response {
|
||||
// SanitizeRequest 消毒请求参数
|
||||
func SanitizeRequest(ctx http.Context, request http.FormRequest) http.Response {
|
||||
errors, err := ctx.Request().ValidateRequest(request)
|
||||
if err != nil {
|
||||
return Error(ctx, http.StatusUnprocessableEntity, err.Error())
|
||||
@@ -50,3 +50,16 @@ func Sanitize(ctx http.Context, request http.FormRequest) http.Response {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Sanitize 消毒参数
|
||||
func Sanitize(ctx http.Context, rules map[string]string) http.Response {
|
||||
validator, err := ctx.Request().Validate(rules)
|
||||
if err != nil {
|
||||
return Error(ctx, http.StatusUnprocessableEntity, err.Error())
|
||||
}
|
||||
if validator.Fails() {
|
||||
return Error(ctx, http.StatusUnprocessableEntity, validator.Errors().One())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ func NewFileController() *FileController {
|
||||
// @Router /panel/file/create [post]
|
||||
func (r *FileController) Create(ctx http.Context) http.Response {
|
||||
var request requests.NotExist
|
||||
sanitize := Sanitize(ctx, &request)
|
||||
sanitize := SanitizeRequest(ctx, &request)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -69,7 +69,7 @@ func (r *FileController) Create(ctx http.Context) http.Response {
|
||||
// @Router /panel/file/content [get]
|
||||
func (r *FileController) Content(ctx http.Context) http.Response {
|
||||
var request requests.Exist
|
||||
sanitize := Sanitize(ctx, &request)
|
||||
sanitize := SanitizeRequest(ctx, &request)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -106,7 +106,7 @@ func (r *FileController) Content(ctx http.Context) http.Response {
|
||||
// @Router /panel/file/save [post]
|
||||
func (r *FileController) Save(ctx http.Context) http.Response {
|
||||
var request requests.Save
|
||||
sanitize := Sanitize(ctx, &request)
|
||||
sanitize := SanitizeRequest(ctx, &request)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -136,7 +136,7 @@ func (r *FileController) Save(ctx http.Context) http.Response {
|
||||
// @Router /panel/file/delete [post]
|
||||
func (r *FileController) Delete(ctx http.Context) http.Response {
|
||||
var request requests.Exist
|
||||
sanitize := Sanitize(ctx, &request)
|
||||
sanitize := SanitizeRequest(ctx, &request)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -162,7 +162,7 @@ func (r *FileController) Delete(ctx http.Context) http.Response {
|
||||
// @Router /panel/file/upload [post]
|
||||
func (r *FileController) Upload(ctx http.Context) http.Response {
|
||||
var request requests.Upload
|
||||
sanitize := Sanitize(ctx, &request)
|
||||
sanitize := SanitizeRequest(ctx, &request)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -203,7 +203,7 @@ func (r *FileController) Upload(ctx http.Context) http.Response {
|
||||
// @Router /panel/file/move [post]
|
||||
func (r *FileController) Move(ctx http.Context) http.Response {
|
||||
var request requests.Move
|
||||
sanitize := Sanitize(ctx, &request)
|
||||
sanitize := SanitizeRequest(ctx, &request)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -233,7 +233,7 @@ func (r *FileController) Move(ctx http.Context) http.Response {
|
||||
// @Router /panel/file/copy [post]
|
||||
func (r *FileController) Copy(ctx http.Context) http.Response {
|
||||
var request requests.Copy
|
||||
sanitize := Sanitize(ctx, &request)
|
||||
sanitize := SanitizeRequest(ctx, &request)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -263,7 +263,7 @@ func (r *FileController) Copy(ctx http.Context) http.Response {
|
||||
// @Router /panel/file/download [get]
|
||||
func (r *FileController) Download(ctx http.Context) http.Response {
|
||||
var request requests.Exist
|
||||
sanitize := Sanitize(ctx, &request)
|
||||
sanitize := SanitizeRequest(ctx, &request)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -292,7 +292,7 @@ func (r *FileController) Download(ctx http.Context) http.Response {
|
||||
// @Router /panel/file/remoteDownload [post]
|
||||
func (r *FileController) RemoteDownload(ctx http.Context) http.Response {
|
||||
var request requests.NotExist
|
||||
sanitize := Sanitize(ctx, &request)
|
||||
sanitize := SanitizeRequest(ctx, &request)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -314,7 +314,7 @@ func (r *FileController) RemoteDownload(ctx http.Context) http.Response {
|
||||
// @Router /panel/file/info [get]
|
||||
func (r *FileController) Info(ctx http.Context) http.Response {
|
||||
var request requests.Exist
|
||||
sanitize := Sanitize(ctx, &request)
|
||||
sanitize := SanitizeRequest(ctx, &request)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -347,7 +347,7 @@ func (r *FileController) Info(ctx http.Context) http.Response {
|
||||
// @Router /panel/file/permission [post]
|
||||
func (r *FileController) Permission(ctx http.Context) http.Response {
|
||||
var request requests.Permission
|
||||
sanitize := Sanitize(ctx, &request)
|
||||
sanitize := SanitizeRequest(ctx, &request)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -375,7 +375,7 @@ func (r *FileController) Permission(ctx http.Context) http.Response {
|
||||
// @Router /panel/file/archive [post]
|
||||
func (r *FileController) Archive(ctx http.Context) http.Response {
|
||||
var request requests.Archive
|
||||
sanitize := Sanitize(ctx, &request)
|
||||
sanitize := SanitizeRequest(ctx, &request)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -401,7 +401,7 @@ func (r *FileController) Archive(ctx http.Context) http.Response {
|
||||
// @Router /panel/file/unArchive [post]
|
||||
func (r *FileController) UnArchive(ctx http.Context) http.Response {
|
||||
var request requests.UnArchive
|
||||
sanitize := Sanitize(ctx, &request)
|
||||
sanitize := SanitizeRequest(ctx, &request)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -426,7 +426,7 @@ func (r *FileController) UnArchive(ctx http.Context) http.Response {
|
||||
// @Router /panel/file/search [post]
|
||||
func (r *FileController) Search(ctx http.Context) http.Response {
|
||||
var request requests.Search
|
||||
sanitize := Sanitize(ctx, &request)
|
||||
sanitize := SanitizeRequest(ctx, &request)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -461,13 +461,13 @@ func (r *FileController) Search(ctx http.Context) http.Response {
|
||||
// @Router /panel/file/list [get]
|
||||
func (r *FileController) List(ctx http.Context) http.Response {
|
||||
var request requests.Exist
|
||||
sanitize := Sanitize(ctx, &request)
|
||||
sanitize := SanitizeRequest(ctx, &request)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
var paginate commonrequests.Paginate
|
||||
paginateSanitize := Sanitize(ctx, &paginate)
|
||||
paginateSanitize := SanitizeRequest(ctx, &paginate)
|
||||
if paginateSanitize != nil {
|
||||
return paginateSanitize
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ func NewFrpController() *FrpController {
|
||||
// @Router /plugins/frp/config [get]
|
||||
func (r *FrpController) GetConfig(ctx http.Context) http.Response {
|
||||
var serviceRequest requests.Service
|
||||
sanitize := controllers.Sanitize(ctx, &serviceRequest)
|
||||
sanitize := controllers.SanitizeRequest(ctx, &serviceRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -54,7 +54,7 @@ func (r *FrpController) GetConfig(ctx http.Context) http.Response {
|
||||
// @Router /plugins/frp/config [post]
|
||||
func (r *FrpController) UpdateConfig(ctx http.Context) http.Response {
|
||||
var updateRequest requests.UpdateConfig
|
||||
sanitize := controllers.Sanitize(ctx, &updateRequest)
|
||||
sanitize := controllers.SanitizeRequest(ctx, &updateRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ func (r *GiteaController) GetConfig(ctx http.Context) http.Response {
|
||||
// @Router /plugins/gitea/config [post]
|
||||
func (r *GiteaController) UpdateConfig(ctx http.Context) http.Response {
|
||||
var updateRequest requests.UpdateConfig
|
||||
sanitize := controllers.Sanitize(ctx, &updateRequest)
|
||||
sanitize := controllers.SanitizeRequest(ctx, &updateRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -15,137 +15,6 @@ func NewPodmanController() *PodmanController {
|
||||
return &PodmanController{}
|
||||
}
|
||||
|
||||
// Status
|
||||
//
|
||||
// @Summary 服务状态
|
||||
// @Description 获取 Podman 服务状态
|
||||
// @Tags 插件-Podman
|
||||
// @Produce json
|
||||
// @Security BearerToken
|
||||
// @Success 200 {object} controllers.SuccessResponse
|
||||
// @Router /plugins/podman/status [get]
|
||||
func (r *PodmanController) Status(ctx http.Context) http.Response {
|
||||
status, err := tools.ServiceStatus("podman")
|
||||
if err != nil {
|
||||
return controllers.Error(ctx, http.StatusInternalServerError, "获取 Podman 服务运行状态失败")
|
||||
}
|
||||
|
||||
return controllers.Success(ctx, status)
|
||||
}
|
||||
|
||||
// IsEnabled
|
||||
//
|
||||
// @Summary 是否启用服务
|
||||
// @Description 获取是否启用 Podman 服务
|
||||
// @Tags 插件-Podman
|
||||
// @Produce json
|
||||
// @Security BearerToken
|
||||
// @Success 200 {object} controllers.SuccessResponse
|
||||
// @Router /plugins/podman/isEnabled [get]
|
||||
func (r *PodmanController) IsEnabled(ctx http.Context) http.Response {
|
||||
enabled, err := tools.ServiceIsEnabled("podman")
|
||||
if err != nil {
|
||||
return controllers.Error(ctx, http.StatusInternalServerError, "获取 Podman 服务启用状态失败")
|
||||
}
|
||||
|
||||
return controllers.Success(ctx, enabled)
|
||||
}
|
||||
|
||||
// Enable
|
||||
//
|
||||
// @Summary 启用服务
|
||||
// @Description 启用 Podman 服务
|
||||
// @Tags 插件-Podman
|
||||
// @Produce json
|
||||
// @Security BearerToken
|
||||
// @Success 200 {object} controllers.SuccessResponse
|
||||
// @Router /plugins/podman/enable [post]
|
||||
func (r *PodmanController) Enable(ctx http.Context) http.Response {
|
||||
if err := tools.ServiceEnable("podman"); err != nil {
|
||||
return controllers.Error(ctx, http.StatusInternalServerError, "启用 Podman 服务失败")
|
||||
}
|
||||
|
||||
return controllers.Success(ctx, nil)
|
||||
}
|
||||
|
||||
// Disable
|
||||
//
|
||||
// @Summary 禁用服务
|
||||
// @Description 禁用 Podman 服务
|
||||
// @Tags 插件-Podman
|
||||
// @Produce json
|
||||
// @Security BearerToken
|
||||
// @Success 200 {object} controllers.SuccessResponse
|
||||
// @Router /plugins/podman/disable [post]
|
||||
func (r *PodmanController) Disable(ctx http.Context) http.Response {
|
||||
if err := tools.ServiceDisable("podman"); err != nil {
|
||||
return controllers.Error(ctx, http.StatusInternalServerError, "禁用 Podman 服务失败")
|
||||
}
|
||||
|
||||
return controllers.Success(ctx, nil)
|
||||
}
|
||||
|
||||
// Restart
|
||||
//
|
||||
// @Summary 重启服务
|
||||
// @Description 重启 Podman 服务
|
||||
// @Tags 插件-Podman
|
||||
// @Produce json
|
||||
// @Security BearerToken
|
||||
// @Success 200 {object} controllers.SuccessResponse
|
||||
// @Router /plugins/podman/restart [post]
|
||||
func (r *PodmanController) Restart(ctx http.Context) http.Response {
|
||||
if err := tools.ServiceRestart("podman"); err != nil {
|
||||
return controllers.Error(ctx, http.StatusInternalServerError, "重启 Podman 服务失败")
|
||||
}
|
||||
|
||||
return controllers.Success(ctx, nil)
|
||||
}
|
||||
|
||||
// Start
|
||||
//
|
||||
// @Summary 启动服务
|
||||
// @Description 启动 Podman 服务
|
||||
// @Tags 插件-Podman
|
||||
// @Produce json
|
||||
// @Security BearerToken
|
||||
// @Success 200 {object} controllers.SuccessResponse
|
||||
// @Router /plugins/podman/start [post]
|
||||
func (r *PodmanController) Start(ctx http.Context) http.Response {
|
||||
if err := tools.ServiceStart("podman"); err != nil {
|
||||
return controllers.Error(ctx, http.StatusInternalServerError, "启动 Podman 服务失败")
|
||||
}
|
||||
|
||||
status, err := tools.ServiceStatus("podman")
|
||||
if err != nil {
|
||||
return controllers.Error(ctx, http.StatusInternalServerError, "获取 Podman 服务运行状态失败")
|
||||
}
|
||||
|
||||
return controllers.Success(ctx, status)
|
||||
}
|
||||
|
||||
// Stop
|
||||
//
|
||||
// @Summary 停止服务
|
||||
// @Description 停止 Podman 服务
|
||||
// @Tags 插件-Podman
|
||||
// @Produce json
|
||||
// @Security BearerToken
|
||||
// @Success 200 {object} controllers.SuccessResponse
|
||||
// @Router /plugins/podman/stop [post]
|
||||
func (r *PodmanController) Stop(ctx http.Context) http.Response {
|
||||
if err := tools.ServiceStop("podman"); err != nil {
|
||||
return controllers.Error(ctx, http.StatusInternalServerError, "停止 Podman 服务失败")
|
||||
}
|
||||
|
||||
status, err := tools.ServiceStatus("podman")
|
||||
if err != nil {
|
||||
return controllers.Error(ctx, http.StatusInternalServerError, "获取 Podman 服务运行状态失败")
|
||||
}
|
||||
|
||||
return controllers.Success(ctx, !status)
|
||||
}
|
||||
|
||||
// GetRegistryConfig
|
||||
//
|
||||
// @Summary 获取注册表配置
|
||||
@@ -176,7 +45,7 @@ func (r *PodmanController) GetRegistryConfig(ctx http.Context) http.Response {
|
||||
// @Router /plugins/podman/registryConfig [post]
|
||||
func (r *PodmanController) UpdateRegistryConfig(ctx http.Context) http.Response {
|
||||
var updateRequest requests.UpdateRegistryConfig
|
||||
sanitize := controllers.Sanitize(ctx, &updateRequest)
|
||||
sanitize := controllers.SanitizeRequest(ctx, &updateRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -222,7 +91,7 @@ func (r *PodmanController) GetStorageConfig(ctx http.Context) http.Response {
|
||||
// @Router /plugins/podman/storageConfig [post]
|
||||
func (r *PodmanController) UpdateStorageConfig(ctx http.Context) http.Response {
|
||||
var updateRequest requests.UpdateStorageConfig
|
||||
sanitize := controllers.Sanitize(ctx, &updateRequest)
|
||||
sanitize := controllers.SanitizeRequest(ctx, &updateRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -23,46 +23,6 @@ func NewPureFtpdController() *PureFtpdController {
|
||||
return &PureFtpdController{}
|
||||
}
|
||||
|
||||
// Status 获取运行状态
|
||||
func (r *PureFtpdController) Status(ctx http.Context) http.Response {
|
||||
status, err := tools.ServiceStatus("pure-ftpd")
|
||||
if err != nil {
|
||||
return controllers.Error(ctx, http.StatusInternalServerError, "获取PureFtpd状态失败")
|
||||
}
|
||||
|
||||
return controllers.Success(ctx, status)
|
||||
}
|
||||
|
||||
// Restart 重启服务
|
||||
func (r *PureFtpdController) Restart(ctx http.Context) http.Response {
|
||||
err := tools.ServiceRestart("pure-ftpd")
|
||||
if err != nil {
|
||||
return controllers.Error(ctx, http.StatusInternalServerError, "重启PureFtpd失败")
|
||||
}
|
||||
|
||||
return controllers.Success(ctx, nil)
|
||||
}
|
||||
|
||||
// Start 启动服务
|
||||
func (r *PureFtpdController) Start(ctx http.Context) http.Response {
|
||||
err := tools.ServiceStart("pure-ftpd")
|
||||
if err != nil {
|
||||
return controllers.Error(ctx, http.StatusInternalServerError, "启动PureFtpd失败")
|
||||
}
|
||||
|
||||
return controllers.Success(ctx, nil)
|
||||
}
|
||||
|
||||
// Stop 停止服务
|
||||
func (r *PureFtpdController) Stop(ctx http.Context) http.Response {
|
||||
err := tools.ServiceStop("pure-ftpd")
|
||||
if err != nil {
|
||||
return controllers.Error(ctx, http.StatusInternalServerError, "停止PureFtpd失败")
|
||||
}
|
||||
|
||||
return controllers.Success(ctx, nil)
|
||||
}
|
||||
|
||||
// List 获取用户列表
|
||||
func (r *PureFtpdController) List(ctx http.Context) http.Response {
|
||||
listRaw, err := tools.Exec("pure-pw list")
|
||||
@@ -110,16 +70,12 @@ func (r *PureFtpdController) List(ctx http.Context) http.Response {
|
||||
|
||||
// Add 添加用户
|
||||
func (r *PureFtpdController) Add(ctx http.Context) http.Response {
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
if sanitize := controllers.Sanitize(ctx, map[string]string{
|
||||
"username": "required",
|
||||
"password": "required|min_len:6",
|
||||
"path": "required",
|
||||
})
|
||||
if err != nil {
|
||||
return controllers.Error(ctx, http.StatusUnprocessableEntity, err.Error())
|
||||
}
|
||||
if validator.Fails() {
|
||||
return controllers.Error(ctx, http.StatusUnprocessableEntity, validator.Errors().One())
|
||||
}); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
username := ctx.Request().Input("username")
|
||||
@@ -133,10 +89,10 @@ func (r *PureFtpdController) Add(ctx http.Context) http.Response {
|
||||
return controllers.Error(ctx, http.StatusUnprocessableEntity, "目录不存在")
|
||||
}
|
||||
|
||||
if err = tools.Chmod(path, 0755); err != nil {
|
||||
if err := tools.Chmod(path, 0755); err != nil {
|
||||
return controllers.Error(ctx, http.StatusUnprocessableEntity, "修改目录权限失败")
|
||||
}
|
||||
if err = tools.Chown(path, "www", "www"); err != nil {
|
||||
if err := tools.Chown(path, "www", "www"); err != nil {
|
||||
return nil
|
||||
}
|
||||
if out, err := tools.Exec(`yes '` + password + `' | pure-pw useradd ` + username + ` -u www -g www -d ` + path); err != nil {
|
||||
@@ -151,14 +107,10 @@ func (r *PureFtpdController) Add(ctx http.Context) http.Response {
|
||||
|
||||
// Delete 删除用户
|
||||
func (r *PureFtpdController) Delete(ctx http.Context) http.Response {
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
if sanitize := controllers.Sanitize(ctx, map[string]string{
|
||||
"username": "required",
|
||||
})
|
||||
if err != nil {
|
||||
return controllers.Error(ctx, http.StatusUnprocessableEntity, err.Error())
|
||||
}
|
||||
if validator.Fails() {
|
||||
return controllers.Error(ctx, http.StatusUnprocessableEntity, validator.Errors().One())
|
||||
}); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
username := ctx.Request().Input("username")
|
||||
@@ -175,15 +127,11 @@ func (r *PureFtpdController) Delete(ctx http.Context) http.Response {
|
||||
|
||||
// ChangePassword 修改密码
|
||||
func (r *PureFtpdController) ChangePassword(ctx http.Context) http.Response {
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
if sanitize := controllers.Sanitize(ctx, map[string]string{
|
||||
"username": "required",
|
||||
"password": "required|min_len:6",
|
||||
})
|
||||
if err != nil {
|
||||
return controllers.Error(ctx, http.StatusUnprocessableEntity, err.Error())
|
||||
}
|
||||
if validator.Fails() {
|
||||
return controllers.Error(ctx, http.StatusUnprocessableEntity, validator.Errors().One())
|
||||
}); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
username := ctx.Request().Input("username")
|
||||
@@ -211,14 +159,10 @@ func (r *PureFtpdController) GetPort(ctx http.Context) http.Response {
|
||||
|
||||
// SetPort 设置端口
|
||||
func (r *PureFtpdController) SetPort(ctx http.Context) http.Response {
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
if sanitize := controllers.Sanitize(ctx, map[string]string{
|
||||
"port": "required",
|
||||
})
|
||||
if err != nil {
|
||||
return controllers.Error(ctx, http.StatusUnprocessableEntity, err.Error())
|
||||
}
|
||||
if validator.Fails() {
|
||||
return controllers.Error(ctx, http.StatusUnprocessableEntity, validator.Errors().One())
|
||||
}); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
port := ctx.Request().Input("port")
|
||||
@@ -241,5 +185,9 @@ func (r *PureFtpdController) SetPort(ctx http.Context) http.Response {
|
||||
}
|
||||
}
|
||||
|
||||
return r.Restart(ctx)
|
||||
if err := tools.ServiceRestart("pure-ftpd"); err != nil {
|
||||
return controllers.Error(ctx, http.StatusInternalServerError, err.Error())
|
||||
}
|
||||
|
||||
return controllers.Success(ctx, nil)
|
||||
}
|
||||
|
||||
@@ -17,43 +17,6 @@ func NewRedisController() *RedisController {
|
||||
return &RedisController{}
|
||||
}
|
||||
|
||||
// Status 获取运行状态
|
||||
func (r *RedisController) Status(ctx http.Context) http.Response {
|
||||
status, err := tools.ServiceStatus("redis")
|
||||
if err != nil {
|
||||
return controllers.Error(ctx, http.StatusInternalServerError, "获取Redis状态失败")
|
||||
}
|
||||
|
||||
return controllers.Success(ctx, status)
|
||||
}
|
||||
|
||||
// Restart 重启服务
|
||||
func (r *RedisController) Restart(ctx http.Context) http.Response {
|
||||
if err := tools.ServiceRestart("redis"); err != nil {
|
||||
return controllers.Error(ctx, http.StatusInternalServerError, "重启Redis失败")
|
||||
}
|
||||
|
||||
return controllers.Success(ctx, nil)
|
||||
}
|
||||
|
||||
// Start 启动服务
|
||||
func (r *RedisController) Start(ctx http.Context) http.Response {
|
||||
if err := tools.ServiceStart("redis"); err != nil {
|
||||
return controllers.Error(ctx, http.StatusInternalServerError, "启动Redis失败")
|
||||
}
|
||||
|
||||
return controllers.Success(ctx, nil)
|
||||
}
|
||||
|
||||
// Stop 停止服务
|
||||
func (r *RedisController) Stop(ctx http.Context) http.Response {
|
||||
if err := tools.ServiceStop("redis"); err != nil {
|
||||
return controllers.Error(ctx, http.StatusInternalServerError, "停止Redis失败")
|
||||
}
|
||||
|
||||
return controllers.Success(ctx, nil)
|
||||
}
|
||||
|
||||
// GetConfig 获取配置
|
||||
func (r *RedisController) GetConfig(ctx http.Context) http.Response {
|
||||
// 获取配置
|
||||
@@ -76,7 +39,11 @@ func (r *RedisController) SaveConfig(ctx http.Context) http.Response {
|
||||
return controllers.Error(ctx, http.StatusInternalServerError, "写入Redis配置失败")
|
||||
}
|
||||
|
||||
return r.Restart(ctx)
|
||||
if err := tools.ServiceRestart("redis"); err != nil {
|
||||
return controllers.Error(ctx, http.StatusInternalServerError, "重启Redis失败")
|
||||
}
|
||||
|
||||
return controllers.Success(ctx, nil)
|
||||
}
|
||||
|
||||
// Load 获取负载
|
||||
|
||||
@@ -32,7 +32,7 @@ func NewRsyncController() *RsyncController {
|
||||
// @Router /plugins/rsync/modules [get]
|
||||
func (r *RsyncController) List(ctx http.Context) http.Response {
|
||||
var paginateRequest commonrequests.Paginate
|
||||
sanitize := controllers.Sanitize(ctx, &paginateRequest)
|
||||
sanitize := controllers.SanitizeRequest(ctx, &paginateRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -125,7 +125,7 @@ func (r *RsyncController) List(ctx http.Context) http.Response {
|
||||
// @Router /plugins/rsync/modules [post]
|
||||
func (r *RsyncController) Create(ctx http.Context) http.Response {
|
||||
var createRequest requests.Create
|
||||
sanitize := controllers.Sanitize(ctx, &createRequest)
|
||||
sanitize := controllers.SanitizeRequest(ctx, &createRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -222,7 +222,7 @@ func (r *RsyncController) Destroy(ctx http.Context) http.Response {
|
||||
// @Router /plugins/rsync/modules/{name} [post]
|
||||
func (r *RsyncController) Update(ctx http.Context) http.Response {
|
||||
var updateRequest requests.Update
|
||||
sanitize := controllers.Sanitize(ctx, &updateRequest)
|
||||
sanitize := controllers.SanitizeRequest(ctx, &updateRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -300,7 +300,7 @@ func (r *RsyncController) GetConfig(ctx http.Context) http.Response {
|
||||
// @Router /plugins/rsync/config [post]
|
||||
func (r *RsyncController) UpdateConfig(ctx http.Context) http.Response {
|
||||
var updateRequest requests.UpdateConfig
|
||||
sanitize := controllers.Sanitize(ctx, &updateRequest)
|
||||
sanitize := controllers.SanitizeRequest(ctx, &updateRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ func (r *SafeController) SetFirewallStatus(ctx http.Context) http.Response {
|
||||
// GetFirewallRules 获取防火墙规则
|
||||
func (r *SafeController) GetFirewallRules(ctx http.Context) http.Response {
|
||||
var paginateRequest commonrequests.Paginate
|
||||
sanitize := Sanitize(ctx, &paginateRequest)
|
||||
sanitize := SanitizeRequest(ctx, &paginateRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ func (r *SettingController) List(ctx http.Context) http.Response {
|
||||
// @Router /panel/setting/update [post]
|
||||
func (r *SettingController) Update(ctx http.Context) http.Response {
|
||||
var updateRequest requests.Update
|
||||
sanitize := Sanitize(ctx, &updateRequest)
|
||||
sanitize := SanitizeRequest(ctx, &updateRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -25,6 +25,12 @@ func NewSystemController() *SystemController {
|
||||
// @Success 200 {object} controllers.SuccessResponse
|
||||
// @Router /panel/system/service/status [get]
|
||||
func (r *SystemController) ServiceStatus(ctx http.Context) http.Response {
|
||||
if sanitize := Sanitize(ctx, map[string]string{
|
||||
"service": "required|string",
|
||||
}); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
service := ctx.Request().Query("service")
|
||||
status, err := tools.ServiceStatus(service)
|
||||
if err != nil {
|
||||
@@ -44,6 +50,12 @@ func (r *SystemController) ServiceStatus(ctx http.Context) http.Response {
|
||||
// @Success 200 {object} controllers.SuccessResponse
|
||||
// @Router /panel/system/service/isEnabled [get]
|
||||
func (r *SystemController) ServiceIsEnabled(ctx http.Context) http.Response {
|
||||
if sanitize := Sanitize(ctx, map[string]string{
|
||||
"service": "required|string",
|
||||
}); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
service := ctx.Request().Query("service")
|
||||
enabled, err := tools.ServiceIsEnabled(service)
|
||||
if err != nil {
|
||||
@@ -63,6 +75,12 @@ func (r *SystemController) ServiceIsEnabled(ctx http.Context) http.Response {
|
||||
// @Success 200 {object} controllers.SuccessResponse
|
||||
// @Router /panel/system/service/enable [post]
|
||||
func (r *SystemController) ServiceEnable(ctx http.Context) http.Response {
|
||||
if sanitize := Sanitize(ctx, map[string]string{
|
||||
"service": "required|string",
|
||||
}); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
service := ctx.Request().Input("service")
|
||||
if err := tools.ServiceEnable(service); err != nil {
|
||||
return Error(ctx, http.StatusInternalServerError, fmt.Sprintf("启用 %s 服务失败", service))
|
||||
@@ -81,6 +99,12 @@ func (r *SystemController) ServiceEnable(ctx http.Context) http.Response {
|
||||
// @Success 200 {object} controllers.SuccessResponse
|
||||
// @Router /panel/system/service/disable [post]
|
||||
func (r *SystemController) ServiceDisable(ctx http.Context) http.Response {
|
||||
if sanitize := Sanitize(ctx, map[string]string{
|
||||
"service": "required|string",
|
||||
}); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
service := ctx.Request().Input("service")
|
||||
if err := tools.ServiceDisable(service); err != nil {
|
||||
return Error(ctx, http.StatusInternalServerError, fmt.Sprintf("禁用 %s 服务失败", service))
|
||||
@@ -99,6 +123,12 @@ func (r *SystemController) ServiceDisable(ctx http.Context) http.Response {
|
||||
// @Success 200 {object} controllers.SuccessResponse
|
||||
// @Router /panel/system/service/restart [post]
|
||||
func (r *SystemController) ServiceRestart(ctx http.Context) http.Response {
|
||||
if sanitize := Sanitize(ctx, map[string]string{
|
||||
"service": "required|string",
|
||||
}); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
service := ctx.Request().Input("service")
|
||||
if err := tools.ServiceRestart(service); err != nil {
|
||||
return Error(ctx, http.StatusInternalServerError, fmt.Sprintf("重启 %s 服务失败", service))
|
||||
@@ -117,6 +147,12 @@ func (r *SystemController) ServiceRestart(ctx http.Context) http.Response {
|
||||
// @Success 200 {object} controllers.SuccessResponse
|
||||
// @Router /panel/system/service/reload [post]
|
||||
func (r *SystemController) ServiceReload(ctx http.Context) http.Response {
|
||||
if sanitize := Sanitize(ctx, map[string]string{
|
||||
"service": "required|string",
|
||||
}); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
service := ctx.Request().Input("service")
|
||||
if err := tools.ServiceReload(service); err != nil {
|
||||
return Error(ctx, http.StatusInternalServerError, fmt.Sprintf("重载 %s 服务失败", service))
|
||||
@@ -135,6 +171,12 @@ func (r *SystemController) ServiceReload(ctx http.Context) http.Response {
|
||||
// @Success 200 {object} controllers.SuccessResponse
|
||||
// @Router /panel/system/service/start [post]
|
||||
func (r *SystemController) ServiceStart(ctx http.Context) http.Response {
|
||||
if sanitize := Sanitize(ctx, map[string]string{
|
||||
"service": "required|string",
|
||||
}); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
service := ctx.Request().Input("service")
|
||||
if err := tools.ServiceStart(service); err != nil {
|
||||
return Error(ctx, http.StatusInternalServerError, fmt.Sprintf("启动 %s 服务失败", service))
|
||||
@@ -153,6 +195,12 @@ func (r *SystemController) ServiceStart(ctx http.Context) http.Response {
|
||||
// @Success 200 {object} controllers.SuccessResponse
|
||||
// @Router /panel/system/service/stop [post]
|
||||
func (r *SystemController) ServiceStop(ctx http.Context) http.Response {
|
||||
if sanitize := Sanitize(ctx, map[string]string{
|
||||
"service": "required|string",
|
||||
}); sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
service := ctx.Request().Input("service")
|
||||
if err := tools.ServiceStop(service); err != nil {
|
||||
return Error(ctx, http.StatusInternalServerError, fmt.Sprintf("停止 %s 服务失败", service))
|
||||
|
||||
@@ -32,7 +32,7 @@ func NewUserController() *UserController {
|
||||
// @Router /panel/user/login [post]
|
||||
func (r *UserController) Login(ctx http.Context) http.Response {
|
||||
var loginRequest requests.Login
|
||||
sanitize := Sanitize(ctx, &loginRequest)
|
||||
sanitize := SanitizeRequest(ctx, &loginRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ func NewWebsiteController() *WebsiteController {
|
||||
// @Router /panel/websites [get]
|
||||
func (r *WebsiteController) List(ctx http.Context) http.Response {
|
||||
var paginateRequest commonrequests.Paginate
|
||||
sanitize := Sanitize(ctx, &paginateRequest)
|
||||
sanitize := SanitizeRequest(ctx, &paginateRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -75,7 +75,7 @@ func (r *WebsiteController) List(ctx http.Context) http.Response {
|
||||
// @Router /panel/websites [post]
|
||||
func (r *WebsiteController) Add(ctx http.Context) http.Response {
|
||||
var addRequest requests.Add
|
||||
sanitize := Sanitize(ctx, &addRequest)
|
||||
sanitize := SanitizeRequest(ctx, &addRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -123,7 +123,7 @@ func (r *WebsiteController) Add(ctx http.Context) http.Response {
|
||||
// @Router /panel/websites/{id} [delete]
|
||||
func (r *WebsiteController) Delete(ctx http.Context) http.Response {
|
||||
var idRequest requests.ID
|
||||
sanitize := Sanitize(ctx, &idRequest)
|
||||
sanitize := SanitizeRequest(ctx, &idRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -210,7 +210,7 @@ func (r *WebsiteController) SaveDefaultConfig(ctx http.Context) http.Response {
|
||||
// @Router /panel/websites/{id}/config [get]
|
||||
func (r *WebsiteController) GetConfig(ctx http.Context) http.Response {
|
||||
var idRequest requests.ID
|
||||
sanitize := Sanitize(ctx, &idRequest)
|
||||
sanitize := SanitizeRequest(ctx, &idRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -241,7 +241,7 @@ func (r *WebsiteController) GetConfig(ctx http.Context) http.Response {
|
||||
// @Router /panel/websites/{id}/config [post]
|
||||
func (r *WebsiteController) SaveConfig(ctx http.Context) http.Response {
|
||||
var saveConfigRequest requests.SaveConfig
|
||||
sanitize := Sanitize(ctx, &saveConfigRequest)
|
||||
sanitize := SanitizeRequest(ctx, &saveConfigRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -267,7 +267,7 @@ func (r *WebsiteController) SaveConfig(ctx http.Context) http.Response {
|
||||
// @Router /panel/websites/{id}/log [delete]
|
||||
func (r *WebsiteController) ClearLog(ctx http.Context) http.Response {
|
||||
var idRequest requests.ID
|
||||
sanitize := Sanitize(ctx, &idRequest)
|
||||
sanitize := SanitizeRequest(ctx, &idRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -298,7 +298,7 @@ func (r *WebsiteController) ClearLog(ctx http.Context) http.Response {
|
||||
// @Router /panel/websites/{id}/updateRemark [post]
|
||||
func (r *WebsiteController) UpdateRemark(ctx http.Context) http.Response {
|
||||
var idRequest requests.ID
|
||||
sanitize := Sanitize(ctx, &idRequest)
|
||||
sanitize := SanitizeRequest(ctx, &idRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -333,7 +333,7 @@ func (r *WebsiteController) UpdateRemark(ctx http.Context) http.Response {
|
||||
// @Router /panel/website/backupList [get]
|
||||
func (r *WebsiteController) BackupList(ctx http.Context) http.Response {
|
||||
var paginateRequest commonrequests.Paginate
|
||||
sanitize := Sanitize(ctx, &paginateRequest)
|
||||
sanitize := SanitizeRequest(ctx, &paginateRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -381,7 +381,7 @@ func (r *WebsiteController) BackupList(ctx http.Context) http.Response {
|
||||
// @Router /panel/websites/{id}/createBackup [post]
|
||||
func (r *WebsiteController) CreateBackup(ctx http.Context) http.Response {
|
||||
var idRequest requests.ID
|
||||
sanitize := Sanitize(ctx, &idRequest)
|
||||
sanitize := SanitizeRequest(ctx, &idRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -455,7 +455,7 @@ func (r *WebsiteController) UploadBackup(ctx http.Context) http.Response {
|
||||
// @Router /panel/websites/{id}/restoreBackup [post]
|
||||
func (r *WebsiteController) RestoreBackup(ctx http.Context) http.Response {
|
||||
var restoreBackupRequest requests.RestoreBackup
|
||||
sanitize := Sanitize(ctx, &restoreBackupRequest)
|
||||
sanitize := SanitizeRequest(ctx, &restoreBackupRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -490,7 +490,7 @@ func (r *WebsiteController) RestoreBackup(ctx http.Context) http.Response {
|
||||
// @Router /panel/website/deleteBackup [delete]
|
||||
func (r *WebsiteController) DeleteBackup(ctx http.Context) http.Response {
|
||||
var deleteBackupRequest requests.DeleteBackup
|
||||
sanitize := Sanitize(ctx, &deleteBackupRequest)
|
||||
sanitize := SanitizeRequest(ctx, &deleteBackupRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -522,7 +522,7 @@ func (r *WebsiteController) DeleteBackup(ctx http.Context) http.Response {
|
||||
// @Router /panel/websites/{id}/resetConfig [post]
|
||||
func (r *WebsiteController) ResetConfig(ctx http.Context) http.Response {
|
||||
var idRequest requests.ID
|
||||
sanitize := Sanitize(ctx, &idRequest)
|
||||
sanitize := SanitizeRequest(ctx, &idRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
@@ -626,7 +626,7 @@ server
|
||||
// @Router /panel/websites/{id}/status [post]
|
||||
func (r *WebsiteController) Status(ctx http.Context) http.Response {
|
||||
var idRequest requests.ID
|
||||
sanitize := Sanitize(ctx, &idRequest)
|
||||
sanitize := SanitizeRequest(ctx, &idRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
@@ -255,10 +255,6 @@ func Plugin() {
|
||||
})
|
||||
r.Prefix("pureftpd").Group(func(route route.Router) {
|
||||
pureFtpdController := plugins.NewPureFtpdController()
|
||||
route.Get("status", pureFtpdController.Status)
|
||||
route.Post("start", pureFtpdController.Start)
|
||||
route.Post("stop", pureFtpdController.Stop)
|
||||
route.Post("restart", pureFtpdController.Restart)
|
||||
route.Get("list", pureFtpdController.List)
|
||||
route.Post("add", pureFtpdController.Add)
|
||||
route.Delete("delete", pureFtpdController.Delete)
|
||||
@@ -268,10 +264,6 @@ func Plugin() {
|
||||
})
|
||||
r.Prefix("redis").Group(func(route route.Router) {
|
||||
redisController := plugins.NewRedisController()
|
||||
route.Get("status", redisController.Status)
|
||||
route.Post("start", redisController.Start)
|
||||
route.Post("stop", redisController.Stop)
|
||||
route.Post("restart", redisController.Restart)
|
||||
route.Get("load", redisController.Load)
|
||||
route.Get("config", redisController.GetConfig)
|
||||
route.Post("config", redisController.SaveConfig)
|
||||
@@ -313,13 +305,6 @@ func Plugin() {
|
||||
})
|
||||
r.Prefix("podman").Group(func(route route.Router) {
|
||||
controller := plugins.NewPodmanController()
|
||||
route.Get("status", controller.Status)
|
||||
route.Get("isEnabled", controller.IsEnabled)
|
||||
route.Post("enable", controller.Enable)
|
||||
route.Post("disable", controller.Disable)
|
||||
route.Post("start", controller.Start)
|
||||
route.Post("stop", controller.Stop)
|
||||
route.Post("restart", controller.Restart)
|
||||
route.Get("registryConfig", controller.GetRegistryConfig)
|
||||
route.Post("registryConfig", controller.UpdateRegistryConfig)
|
||||
route.Get("storageConfig", controller.GetStorageConfig)
|
||||
|
||||
Reference in New Issue
Block a user