refactor(autocert): extract types to dedicated package and switch to context-based provider access

Move CertInfo struct from provider.go to internal/autocert/types/cert_info.go and
replace global ActiveProvider.Load() with context-based autocertctx.FromCtx() pattern in API handlers.
This improves separation of concerns and eliminates global state dependency in request handling.
This commit is contained in:
yusing
2026-02-10 16:49:34 +08:00
parent 99f8bc1fb9
commit 3aba728a3a
5 changed files with 27 additions and 23 deletions

View File

@@ -0,0 +1,10 @@
package autocert
type CertInfo struct {
Subject string `json:"subject"`
Issuer string `json:"issuer"`
NotBefore int64 `json:"not_before"`
NotAfter int64 `json:"not_after"`
DNSNames []string `json:"dns_names"`
EmailAddresses []string `json:"email_addresses"`
} // @name CertInfo

View File

@@ -1,13 +1,17 @@
package autocert
import (
"context"
"crypto/tls"
"github.com/yusing/goutils/task"
)
type Provider interface {
GetCert(*tls.ClientHelloInfo) (*tls.Certificate, error)
ScheduleRenewalAll(task.Parent)
GetCert(hello *tls.ClientHelloInfo) (*tls.Certificate, error)
GetCertInfos() ([]CertInfo, error)
ScheduleRenewalAll(parent task.Parent)
ObtainCertAll() error
ForceExpiryAll() bool
WaitRenewalDone(ctx context.Context) bool
}