fix!: Redirect old /remote-nodes/logs to /remote-nodes/id/{id} #155

The old `/remote-nodes/logs/?node_id={id}` is not being used anymore
and should be redirected to the new path: `/remote-nodes/id/{id}`.

Remove the route once search engines result shows the new path
This commit is contained in:
Cristian Ditaputratama 2024-11-06 21:34:05 +07:00
parent 5fb88865d0
commit 2e31824910
Signed by: ditatompel
GPG key ID: 31D3D06D77950979
2 changed files with 17 additions and 0 deletions

View file

@ -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{

View file

@ -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")