mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 09:13:49 +08:00
feat: 优化网站证书更新
This commit is contained in:
@@ -57,7 +57,7 @@ type WebsiteUpdateStatus struct {
|
||||
}
|
||||
|
||||
type WebsiteUpdateCert struct {
|
||||
Name uint `json:"name" validate:"required|exists:websites,name"`
|
||||
Name string `json:"name" validate:"required|exists:websites,name"`
|
||||
Cert string `json:"cert" validate:"required"`
|
||||
Key string `json:"key" validate:"required"`
|
||||
}
|
||||
|
||||
@@ -159,6 +159,7 @@ func (route *Http) Register(r *chi.Mux) {
|
||||
r.Get("/rewrites", route.website.GetRewrites)
|
||||
r.Get("/default_config", route.website.GetDefaultConfig)
|
||||
r.Post("/default_config", route.website.UpdateDefaultConfig)
|
||||
r.Post("/cert", route.website.UpdateCert)
|
||||
r.Get("/", route.website.List)
|
||||
r.Post("/", route.website.Create)
|
||||
r.Get("/{id}", route.website.Get)
|
||||
@@ -168,7 +169,6 @@ func (route *Http) Register(r *chi.Mux) {
|
||||
r.Post("/{id}/update_remark", route.website.UpdateRemark)
|
||||
r.Post("/{id}/reset_config", route.website.ResetConfig)
|
||||
r.Post("/{id}/status", route.website.UpdateStatus)
|
||||
r.Post("/{id}/cert", route.website.UpdateCert)
|
||||
r.Post("/{id}/obtain_cert", route.website.ObtainCert)
|
||||
})
|
||||
|
||||
|
||||
@@ -67,6 +67,22 @@ func (s *WebsiteService) UpdateDefaultConfig(w http.ResponseWriter, r *http.Requ
|
||||
Success(w, nil)
|
||||
}
|
||||
|
||||
// UpdateCert 用于自动化工具更新证书
|
||||
func (s *WebsiteService) UpdateCert(w http.ResponseWriter, r *http.Request) {
|
||||
req, err := Bind[request.WebsiteUpdateCert](r)
|
||||
if err != nil {
|
||||
Error(w, http.StatusUnprocessableEntity, "%v", err)
|
||||
return
|
||||
}
|
||||
|
||||
if err = s.websiteRepo.UpdateCert(req); err != nil {
|
||||
Error(w, http.StatusInternalServerError, "%v", err)
|
||||
return
|
||||
}
|
||||
|
||||
Success(w, nil)
|
||||
}
|
||||
|
||||
func (s *WebsiteService) List(w http.ResponseWriter, r *http.Request) {
|
||||
req, err := Bind[request.Paginate](r)
|
||||
if err != nil {
|
||||
@@ -212,22 +228,6 @@ func (s *WebsiteService) UpdateStatus(w http.ResponseWriter, r *http.Request) {
|
||||
Success(w, nil)
|
||||
}
|
||||
|
||||
// UpdateCert 用于自动化工具更新证书
|
||||
func (s *WebsiteService) UpdateCert(w http.ResponseWriter, r *http.Request) {
|
||||
req, err := Bind[request.WebsiteUpdateCert](r)
|
||||
if err != nil {
|
||||
Error(w, http.StatusUnprocessableEntity, "%v", err)
|
||||
return
|
||||
}
|
||||
|
||||
if err = s.websiteRepo.UpdateCert(req); err != nil {
|
||||
Error(w, http.StatusInternalServerError, "%v", err)
|
||||
return
|
||||
}
|
||||
|
||||
Success(w, nil)
|
||||
}
|
||||
|
||||
func (s *WebsiteService) ObtainCert(w http.ResponseWriter, r *http.Request) {
|
||||
req, err := Bind[request.ID](r)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user