mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-23 00:38:33 +02:00
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:
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/yusing/godoxy/internal/autocert"
|
||||
autocertctx "github.com/yusing/godoxy/internal/autocert/types"
|
||||
apitypes "github.com/yusing/goutils/apitypes"
|
||||
)
|
||||
|
||||
@@ -21,7 +22,7 @@ import (
|
||||
// @Failure 500 {object} apitypes.ErrorResponse "Internal server error"
|
||||
// @Router /cert/info [get]
|
||||
func Info(c *gin.Context) {
|
||||
provider := autocert.ActiveProvider.Load()
|
||||
provider := autocertctx.FromCtx(c.Request.Context())
|
||||
if provider == nil {
|
||||
c.JSON(http.StatusNotFound, apitypes.Error("autocert is not enabled"))
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user