- Added CertificateHandler for listing certificates. - Created health check handler for service metadata. - Introduced ImportHandler for handling Caddyfile imports. - Developed ProxyHostHandler for CRUD operations on proxy hosts. - Added RemoteServerHandler for managing remote servers. - Implemented UserHandler for initial setup and user management. - Created authentication middleware for secure API access. - Registered all handlers and routes in the main API router. - Added tests for proxy host and remote server handlers.
28 lines
580 B
Go
28 lines
580 B
Go
package handlers
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/Wikid82/CaddyProxyManagerPlus/backend/internal/services"
|
|
)
|
|
|
|
type CertificateHandler struct {
|
|
service *services.CertificateService
|
|
}
|
|
|
|
func NewCertificateHandler(service *services.CertificateService) *CertificateHandler {
|
|
return &CertificateHandler{service: service}
|
|
}
|
|
|
|
func (h *CertificateHandler) List(c *gin.Context) {
|
|
certs, err := h.service.ListCertificates()
|
|
if err != nil {
|
|
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, certs)
|
|
}
|