Skip to content

Commit 72dc188

Browse files
committed
add domains
1 parent 415c3d1 commit 72dc188

File tree

4 files changed

+22
-44
lines changed

4 files changed

+22
-44
lines changed

internal/interfaces/api/handler/handledomain.go

Lines changed: 18 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -552,56 +552,33 @@ func (s *Handler) GetDomainsHandler(res http.ResponseWriter, req *http.Request)
552552
return
553553
}
554554

555+
// 检查 PublishEnabled 权限
556+
if !license.GetFeatures().PublishEnabled {
557+
s.jsonError(res, "Publish feature not enabled for this license plan", http.StatusForbidden)
558+
return
559+
}
560+
555561
// 获取 PublishDomain 记录
556562
pd, err := s.contentApp.GetPublishDomainByKey(license.LicenseKey)
557563
if err != nil {
558564
s.jsonError(res, "Publish domain not found", http.StatusNotFound)
559565
return
560566
}
561567

562-
// 构建响应
563-
response := map[string]interface{}{
564-
"license_key": license.LicenseKey,
565-
"platform_domain": s.adminApp.Domain(),
566-
"features": map[string]interface{}{
567-
"custom_domain_enabled": license.GetFeatures().CustomDomain,
568-
"max_custom_domains": 1,
569-
},
570-
}
571-
572-
// SubDomain 信息
573-
if pd.SubDomain != "" {
574-
response["subdomain"] = map[string]interface{}{
575-
"name": pd.SubDomain,
576-
"full_domain": fmt.Sprintf("%s.%s", pd.SubDomain, s.adminApp.Domain()),
577-
"status": "active",
578-
}
579-
}
580-
581-
// 自定义域名信息
582-
if pd.CusDomain != "" {
583-
customDomainInfo := map[string]interface{}{
584-
"domain": pd.CusDomain,
585-
}
586-
587-
// ✅ 执行 TLS 检测获取实时状态
588-
tlsResult := s.caddyClient.GetChecker().CheckTLS(pd.CusDomain)
589-
590-
customDomainInfo["status"] = tlsResult.TLSStatus
591-
customDomainInfo["tls_ready"] = tlsResult.TLSReady
592-
593-
if tlsResult.TLSReady && tlsResult.CertInfo != nil {
594-
customDomainInfo["certificate"] = map[string]interface{}{
595-
"status": tlsResult.CertInfo.Status,
596-
"issuer": tlsResult.CertInfo.Issuer,
597-
"expires_at": tlsResult.CertInfo.NotAfter,
598-
}
599-
}
600-
601-
response["custom_domain"] = customDomainInfo
568+
// 获取 SubDomain 记录
569+
sd, err := s.contentApp.GetSubDomainByKey(pd.SubDomain)
570+
if err != nil {
571+
s.jsonError(res, "Subdomain not found", http.StatusNotFound)
572+
return
602573
}
603574

604-
s.jsonResponse(res, response)
575+
s.jsonResponse(res, map[string]interface{}{
576+
"subdomain": sd.Sub,
577+
"full_domain": fmt.Sprintf("%s.%s", sd.Sub, s.adminApp.Domain()),
578+
"cus_domain": pd.CusDomain,
579+
"folder": pd.Folder,
580+
"created_at": sd.Timestamp,
581+
})
605582
}
606583

607584
// ========== 辅助函数 ==========

internal/interfaces/api/handlers.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ func (s *Server) registerLicenseHandler() {
4646
s.mux.HandleFunc("/api/license/domain/check", s.wrapContentHandler(s.handler.CheckDomainHandler))
4747
s.mux.HandleFunc("/api/license/domain/add", s.wrapContentHandler(s.handler.AddDomainHandler))
4848
s.mux.HandleFunc("/api/license/domain/remove", s.wrapContentHandler(s.handler.RemoveDomainHandler))
49-
s.mux.HandleFunc("/api/license/domains", s.wrapContentHandler(s.handler.GetDomainsHandler))
5049
s.mux.HandleFunc("/api/license/domain/https-status", s.wrapContentHandler(s.handler.DomainSSLStatusHandler))
50+
51+
s.mux.HandleFunc("/api/license/domains", s.wrapContentHandler(s.handler.GetDomainsHandler))
5152
}
5253

5354
func (s *Server) registerContentHandler() {

internal/interfaces/cli/vercurr.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ package cli
33
var CurrentVersion = Version{
44
Major: 0,
55
Minor: 2,
6-
PatchLevel: 25,
6+
PatchLevel: 26,
77
Suffix: "",
88
}

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.2.25",
2+
"version": "0.2.26",
33
"name": "Hugoverse",
44
"description": "Headless CMS for Hugo",
55
"author": "sunwei",

0 commit comments

Comments
 (0)