From 54c0845f2848a92cb1eb686fdfc015f3f22dea9f Mon Sep 17 00:00:00 2001 From: Robin Olsen Date: Fri, 13 Feb 2026 13:38:54 +0100 Subject: [PATCH] handles routes in routes --- pkg/web/handler/handler.go | 21 ------------------ pkg/web/handler/pages.go | 44 -------------------------------------- 2 files changed, 65 deletions(-) delete mode 100644 pkg/web/handler/handler.go delete mode 100644 pkg/web/handler/pages.go diff --git a/pkg/web/handler/handler.go b/pkg/web/handler/handler.go deleted file mode 100644 index 597333c..0000000 --- a/pkg/web/handler/handler.go +++ /dev/null @@ -1,21 +0,0 @@ -package handler - -import ( - "net/http" - - "github.com/LazyBachelor/LazyPM/internal/service" -) - -type Route struct { - Pattern string - Handler http.Handler -} - -func GetRoutes(svc *service.Services) []Route { - var routes []Route - - routes = append(routes, PagesRoutes(svc)...) - routes = append(routes, IssuesRoutes(svc)...) - - return routes -} diff --git a/pkg/web/handler/pages.go b/pkg/web/handler/pages.go deleted file mode 100644 index 82c6c63..0000000 --- a/pkg/web/handler/pages.go +++ /dev/null @@ -1,44 +0,0 @@ -package handler - -import ( - "net/http" - - "github.com/LazyBachelor/LazyPM/internal/service" - "github.com/LazyBachelor/LazyPM/pkg/web/components" - "github.com/LazyBachelor/LazyPM/pkg/web/routes" -) - -func PagesRoutes(svc *service.Services) []Route { - return []Route{ - {Pattern: "/", Handler: IndexHandler(svc)}, - } -} - -func IndexHandler(svc *service.Services) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - - if r.URL.Path != "/" { - handleNotFound(w, r) - return - } - - issues, err := svc.Beads.AllIssues(r.Context()) - - if err != nil { - http.Error(w, "Failed to retrieve issues", - http.StatusInternalServerError) - return - } - - props := routes.IndexProps{ - IssueTable: components.IssueTableProps{ - Issues: issues, - }, - } - routes.Index(props).Render(r.Context(), w) - } -} - -func handleNotFound(w http.ResponseWriter, _ *http.Request) { - http.Error(w, "Page not found", http.StatusNotFound) -}