Files
Charon/backend/internal/api/handlers/uptime_handler.go
T
Wikid82 1b12dbaf8b feat: Update frontend deps, improve backend coverage, add notification/uptime features
- Upgrade frontend to Node v20
- Fix frontend tests
- Improve backend test coverage to >80%
- Add Notification Provider and Uptime monitoring features
- Fix SQLite locking issues in tests
2025-11-23 20:42:18 +00:00

39 lines
904 B
Go

package handlers
import (
"net/http"
"strconv"
"github.com/Wikid82/CaddyProxyManagerPlus/backend/internal/services"
"github.com/gin-gonic/gin"
)
type UptimeHandler struct {
service *services.UptimeService
}
func NewUptimeHandler(service *services.UptimeService) *UptimeHandler {
return &UptimeHandler{service: service}
}
func (h *UptimeHandler) List(c *gin.Context) {
monitors, err := h.service.ListMonitors()
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to list monitors"})
return
}
c.JSON(http.StatusOK, monitors)
}
func (h *UptimeHandler) GetHistory(c *gin.Context) {
id := c.Param("id")
limit, _ := strconv.Atoi(c.DefaultQuery("limit", "50"))
history, err := h.service.GetMonitorHistory(id, limit)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to get history"})
return
}
c.JSON(http.StatusOK, history)
}