2025-03-20 22:14:45 +01:00

35 lines
1.2 KiB
Go

package routes
import (
"backea/internal/backup"
"backea/internal/web/handlers"
"fmt"
"github.com/labstack/echo/v4"
)
// RegisterRoutes sets up all the routes for the web application
func RegisterRoutes(e *echo.Echo, factory *backup.BackupFactory) {
// Create handlers with backup factory
homeHandler := handlers.NewHomepageHandler(factory)
actionsHandler := handlers.NewBackupActionsHandler(factory)
// Register main routes
e.GET("/", homeHandler.Home)
// Register HTMX API endpoints for lazy loading
e.GET("/api/service-group/:groupName/header", homeHandler.ServiceGroupHeader)
e.GET("/api/service-group/:groupName/backups", homeHandler.ServiceGroupBackups)
e.GET("/api/service-group/:groupName/all-backups", homeHandler.ServiceGroupAllBackups)
// Register backup action routes - using named parameter for backupID
e.POST("/api/backups/:backupID/restore", actionsHandler.RestoreBackup)
e.GET("/api/backups/restore-form", actionsHandler.RestoreBackupForm)
e.GET("/api/backups/download", actionsHandler.DownloadBackup)
// Add this after routes registration but before server start to see all routes
for _, route := range e.Routes() {
fmt.Printf("Method: %s, Path: %s, Handler: %s\n", route.Method, route.Path, route.Name)
}
}