heroagent/pkg/servers/ui/routes/router.go
2025-05-23 15:56:35 +04:00

51 lines
1.8 KiB
Go

package routes
import (
"git.ourworld.tf/herocode/heroagent/pkg/servers/ui/controllers"
"git.ourworld.tf/herocode/heroagent/pkg/servers/ui/models"
"github.com/gofiber/fiber/v2"
)
// SetupRoutes configures the application's routes.
func SetupRoutes(app *fiber.App) {
// Initialize services and controllers
// For now, using the mock process manager
processManagerService := models.NewMockProcessManager()
dashboardController := controllers.NewDashboardController()
processController := controllers.NewProcessController(processManagerService)
authController := controllers.NewAuthController()
// --- Public Routes ---
// Login and Logout
app.Get("/login", authController.ShowLoginPage)
app.Post("/login", authController.HandleLogin)
app.Get("/logout", authController.HandleLogout)
// --- Authenticated Routes ---
// TODO: Add middleware here to protect routes that require authentication.
// For example:
// authenticated := app.Group("/", authMiddleware) // Assuming authMiddleware is defined
// authenticated.Get("/", dashboardController.ShowDashboard)
// authenticated.Get("/processes", processController.ShowProcessManager)
// authenticated.Post("/processes/kill/:pid", processController.HandleKillProcess)
// For now, routes are public for development ease
app.Get("/", dashboardController.ShowDashboard)
app.Get("/processes", processController.ShowProcessManager)
app.Post("/processes/kill/:pid", processController.HandleKillProcess)
}
// TODO: Implement authMiddleware
// func authMiddleware(c *fiber.Ctx) error {
// // Check for session/token
// // If not authenticated, redirect to /login
// // If authenticated, c.Next()
// // Example:
// // if c.Cookies("session_token") == "" {
// // return c.Redirect("/login")
// // }
// return c.Next()
// }