diff --git a/internal/handler/response.go b/internal/handler/response.go index bf375cc..4f31f9b 100644 --- a/internal/handler/response.go +++ b/internal/handler/response.go @@ -13,6 +13,19 @@ import ( "github.com/gofiber/fiber/v2/middleware/adaptor" ) +// Redirect old `/remote-nodes/logs/?node_id={id}` path to `/remote-nodes/id/{id}` +// +// This is temporary handler to redirect old path to new one. Once search +// engine results updated to the new path, this handler should be removed. +func (s *fiberServer) redirectLogs(c *fiber.Ctx) error { + id := c.QueryInt("node_id", 0) + if id == 0 { + return c.Redirect("/remote-nodes", fiber.StatusMovedPermanently) + } + + return c.Redirect(fmt.Sprintf("/remote-nodes/id/%d", id), fiber.StatusMovedPermanently) +} + // Render Home Page func (s *fiberServer) homeHandler(c *fiber.Ctx) error { p := views.Meta{ diff --git a/internal/handler/routes.go b/internal/handler/routes.go index 5038b09..12cf8db 100644 --- a/internal/handler/routes.go +++ b/internal/handler/routes.go @@ -7,6 +7,10 @@ func (s *fiberServer) Routes() { s.App.Get("/add-node", s.addNodeHandler) s.App.Put("/add-node", s.addNodeHandler) + // This is temporary route to redirect old path to new one. Once search + // engine results updated to the new path, this route should be removed. + s.App.Get("/remote-nodes/logs", s.redirectLogs) + // V1 API routes v1 := s.App.Group("/api/v1")