fix: normalize domains to lowercase in caddy config, improve error logging

This commit is contained in:
Wikid82
2025-11-22 21:47:40 -05:00
parent c93a5edd0e
commit 3730ce3152
2 changed files with 4 additions and 2 deletions
@@ -1,6 +1,7 @@
package handlers
import (
"fmt"
"net/http"
"github.com/gin-gonic/gin"
@@ -70,9 +71,9 @@ func (h *ProxyHostHandler) Create(c *gin.Context) {
if h.caddyManager != nil {
if err := h.caddyManager.ApplyConfig(c.Request.Context()); err != nil {
// Rollback: delete the created host if config application fails
fmt.Printf("Error applying config: %v\n", err) // Log to stdout
if deleteErr := h.service.Delete(host.ID); deleteErr != nil {
// Log this critical failure (failed to rollback)
// In a real app, we might want to use a proper logger here
fmt.Printf("Critical: Failed to rollback host %d: %v\n", host.ID, deleteErr)
}
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to apply configuration: " + err.Error()})
return