From 0f386ad4567d6f837f66f2170c4d01d73d0a9d59 Mon Sep 17 00:00:00 2001
From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com>
Date: Mon, 25 May 2026 22:04:25 -0500
Subject: [PATCH] fix: botones start/stop/restart usan POST; agrega webhook
Coolify
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- CoolifyApplicationStart/Stop/Restart cambian GET → POST (Coolify API requiere POST)
- Nuevo endpoint público POST /webhooks/coolify para recibir notificaciones
de deployment/restart desde Coolify Settings → Notifications → Webhook
- UI: muestra URL del webhook en modal de config para fácil copia
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
resources/views/coolify.html | 11 ++++++++++
rest/controllers/coolify_controller.go | 28 +++++++++++++++++++++++---
rest/routes/publicas.go | 2 ++
3 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/resources/views/coolify.html b/resources/views/coolify.html
index 6e4c915..3dc6400 100644
--- a/resources/views/coolify.html
+++ b/resources/views/coolify.html
@@ -442,6 +442,17 @@
+
+
+
URL Webhook (notificaciones)
+
Copia esta URL en Coolify → Settings → Notifications → Webhook para recibir eventos de deployment/restart.
+
+
+
+
+
diff --git a/rest/controllers/coolify_controller.go b/rest/controllers/coolify_controller.go
index 18cd072..f61aaeb 100644
--- a/rest/controllers/coolify_controller.go
+++ b/rest/controllers/coolify_controller.go
@@ -161,13 +161,13 @@ func CoolifyApplicationEnvDelete(c *fiber.Ctx) error {
return coolifyProxy(c, http.MethodDelete, "/applications/"+c.Params("uuid")+"/envs/"+c.Params("env_id"))
}
func CoolifyApplicationStart(c *fiber.Ctx) error {
- return coolifyProxy(c, http.MethodGet, "/applications/"+c.Params("uuid")+"/start")
+ return coolifyProxy(c, http.MethodPost, "/applications/"+c.Params("uuid")+"/start")
}
func CoolifyApplicationStop(c *fiber.Ctx) error {
- return coolifyProxy(c, http.MethodGet, "/applications/"+c.Params("uuid")+"/stop")
+ return coolifyProxy(c, http.MethodPost, "/applications/"+c.Params("uuid")+"/stop")
}
func CoolifyApplicationRestart(c *fiber.Ctx) error {
- return coolifyProxy(c, http.MethodGet, "/applications/"+c.Params("uuid")+"/restart")
+ return coolifyProxy(c, http.MethodPost, "/applications/"+c.Params("uuid")+"/restart")
}
func CoolifyApplicationDeployments(c *fiber.Ctx) error {
return coolifyProxy(c, http.MethodGet, "/applications/"+c.Params("uuid")+"/deployments")
@@ -256,3 +256,25 @@ func CoolifyCurrentTeam(c *fiber.Ctx) error {
func CoolifyTeamMembers(c *fiber.Ctx) error {
return coolifyProxy(c, http.MethodGet, "/teams/current/members")
}
+
+// CoolifyWebhook recibe notificaciones push de Coolify (deployment events, etc.)
+// Configura en Coolify UI → Settings → Notifications → Webhook → URL: https://admin.u-site.app/app/coolify/webhook
+func CoolifyWebhook(c *fiber.Ctx) error {
+ var payload map[string]interface{}
+ if err := c.BodyParser(&payload); err != nil {
+ // acepta también body vacío o texto plano
+ payload = map[string]interface{}{"raw": string(c.Body())}
+ }
+
+ // Log del evento para debug
+ eventType := ""
+ if t, ok := payload["type"].(string); ok {
+ eventType = t
+ } else if t, ok := payload["event"].(string); ok {
+ eventType = t
+ }
+
+ _ = eventType // en el futuro: guardar en DB, enviar push, etc.
+
+ return c.JSON(fiber.Map{"ok": true})
+}
diff --git a/rest/routes/publicas.go b/rest/routes/publicas.go
index 4bfb814..bc78ed7 100755
--- a/rest/routes/publicas.go
+++ b/rest/routes/publicas.go
@@ -23,6 +23,8 @@ func RutasPublicas(web fiber.Router) {
// Webhook entrante por integración SaaS (token único por config)
web.Post("/webhooks/saas-in/:token", controllers.SaasWebhookInHandler)
web.Get("/webhooks/saas-in/:token", controllers.SaasWebhookInHandler) // algunos SaaS verifican con GET
+ // Coolify notifica eventos de deployment/restart aquí (configurar en Coolify → Settings → Notifications → Webhook)
+ web.Post("/webhooks/coolify", controllers.CoolifyWebhook)
// ─── Página de confirmación de pago ───────────────────────────────────
web.Get("/pago-exitoso", apiControllers.PagoExitosoPage)