From c1c72274cf3593260a6880c9722d1f99e6d9e93c Mon Sep 17 00:00:00 2001 From: Christian Ditaputratama Date: Thu, 7 Nov 2024 00:59:57 +0700 Subject: [PATCH] feat: Added robots.txt route --- internal/handler/response.go | 5 +++++ internal/handler/routes.go | 1 + 2 files changed, 6 insertions(+) diff --git a/internal/handler/response.go b/internal/handler/response.go index be5de1a..94ad689 100644 --- a/internal/handler/response.go +++ b/internal/handler/response.go @@ -26,6 +26,11 @@ func (s *fiberServer) redirectLogs(c *fiber.Ctx) error { return c.Redirect(fmt.Sprintf("/remote-nodes/id/%d", id), fiber.StatusMovedPermanently) } +// Render robots.txt +func (s *fiberServer) robotsTxtHandler(c *fiber.Ctx) error { + return c.SendString("User-agent: *\nAllow: /\n") +} + // 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 0030cd7..1d591fe 100644 --- a/internal/handler/routes.go +++ b/internal/handler/routes.go @@ -2,6 +2,7 @@ package handler func (s *fiberServer) Routes() { s.App.Get("/", s.homeHandler) + s.App.Get("/robots.txt", s.robotsTxtHandler) s.App.Get("/remote-nodes", s.remoteNodesHandler) s.App.Get("/remote-nodes/id/:id", s.nodeHandler) s.App.Get("/add-node", s.addNodeHandler)